]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix for memset glibc bug crash
authoreviltypeguy <eviltypeguy@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Jan 2002 06:35:22 +0000 (06:35 +0000)
committereviltypeguy <eviltypeguy@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Jan 2002 06:35:22 +0000 (06:35 +0000)
(why would it read from PROT_WRITE only memory? silly thing...)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1447 d7cf8633-e32d-0410-b094-e92efae38249

snd_dma.c

index aa51cbfd9c69c745f5ad9bff174620f837dcc471..e68e96691045524dd6d9ffe2f710c2a44f7f88b9 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -617,7 +617,16 @@ void S_ClearBuffer (void)
        else
 #endif
        {
-               memset(shm->buffer, clear, shm->samples * shm->samplebits/8);
+               int             setsize = shm->samples * shm->samplebits / 8;
+               char    *buf = shm->buffer;
+
+               while (setsize--)
+                       *buf++ = 0;
+
+// on i586/i686 optimized versions of glibc, glibc *wrongly* IMO,
+// reads the memory area before writing to it causing a seg fault
+// since the memory is PROT_WRITE only and not PROT_READ|PROT_WRITE
+//             memset(shm->buffer, clear, shm->samples * shm->samplebits/8);
        }
 }