fix segfault; from jakemsr@, maintainer ok.

This commit is contained in:
sthen 2009-02-10 00:32:43 +00:00
parent 5cd94d3cb0
commit af1c8871b5
2 changed files with 40 additions and 2 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.3 2009/02/08 22:31:58 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.4 2009/02/10 00:32:43 sthen Exp $
COMMENT = platform game featuring buggers equipped with weapons
V = 0.5.0
DISTNAME = teeworlds-${V}-src
PKGNAME = teeworlds-${V}p1
PKGNAME = teeworlds-${V}p2
CATEGORIES = games
MAINTAINER = Jonathan Armani <dbd@asystant.net>

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-src_engine_client_ec_snd_c,v 1.1 2009/02/10 00:32:43 sthen Exp $
--- src/engine/client/ec_snd.c.orig Tue Jan 27 11:41:17 2009
+++ src/engine/client/ec_snd.c Tue Jan 27 12:30:08 2009
@@ -139,10 +139,19 @@ static int iabs(int i)
static void mix(short *final_out, unsigned frames)
{
- int mix_buffer[MAX_FRAMES*2] = {0};
- int i, s;
+ int *mix_buffer;
+ int i, s, mix_buffer_size;
int master_vol;
+ mix_buffer_size = frames * 2 * sizeof(int);
+ mix_buffer = malloc(mix_buffer_size);
+ if (mix_buffer == NULL)
+ {
+ printf("malloc failed");
+ return;
+ }
+ bzero(mix_buffer, mix_buffer_size);
+
/* aquire lock while we are mixing */
lock_wait(sound_lock);
@@ -239,6 +248,12 @@ static void mix(short *final_out, unsigned frames)
#if defined(CONF_ARCH_ENDIAN_BIG)
swap_endian(final_out, sizeof(short), frames * 2);
#endif
+
+ if(mix_buffer != NULL) {
+ free(mix_buffer);
+ mix_buffer = NULL;
+ }
+
}
static void sdlcallback(void *unused, Uint8 *stream, int len)