fix rounding error that caused a memory block overflow in steelstorm when loading...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 3 Mar 2011 15:56:55 +0000 (15:56 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 3 Mar 2011 15:56:55 +0000 (15:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10886 d7cf8633-e32d-0410-b094-e92efae38249

snd_mem.c

index 75f9e82..11b0a9d 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -84,7 +84,7 @@ snd_buffer_t *Snd_CreateSndBuffer (const unsigned char *samples, unsigned int sa
        size_t newsampleframes, memsize;
        snd_buffer_t* sb;
 
-       newsampleframes = (size_t) ((double)sampleframes * (double)sb_speed / (double)in_format->speed);
+       newsampleframes = (size_t) ceil((double)sampleframes * (double)sb_speed / (double)in_format->speed);
 
        memsize = newsampleframes * in_format->channels * in_format->width;
        memsize += sizeof (*sb) - sizeof (sb->samples);