shithub: choc

Download patch

ref: 33b6861e500ee5483e89e325008fea68627efbd3
parent: 5657765ba4bcae2caa8e60d162a6f9e7873f1e41
author: Simon Howard <fraggle@gmail.com>
date: Sun Oct 2 16:23:04 EDT 2005

Guard against music lumps containing non-MUS data, document in bugs list

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 152

--- a/BUGS
+++ b/BUGS
@@ -20,3 +20,10 @@
   big-endian systems.  On 64-bit systems savegames may be entirely
   nonfunctional.
 
+* Some music which works in Vanilla Doom does not work in Chocolate Doom
+
+  An example is the music on the title screen of deca.wad.  The music here
+  does not seem to be in the .mus format, yet somehow plays in Vanilla
+  Doom nonetheless.  Attempting to convert it using the mmus2mid code 
+  used in Chocolate Doom results in a crash.
+
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_sound.c 102 2005-09-11 23:57:08Z fraggle $
+// $Id: i_sound.c 152 2005-10-02 20:23:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.20  2005/10/02 20:23:04  fraggle
+// Guard against music lumps containing non-MUS data, document in bugs list
+//
 // Revision 1.19  2005/09/11 23:57:08  fraggle
 // Remove temporary MIDI files generated by sound code.
 //
@@ -93,7 +96,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_sound.c 102 2005-09-11 23:57:08Z fraggle $";
+rcsid[] = "$Id: i_sound.c 152 2005-10-02 20:23:04Z fraggle $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -568,6 +571,12 @@
     int midlen;
 
     if (!music_initialised)
+        return NULL;
+    
+    // MUS files begin with "MUS"
+    // Reject anything which doesnt have this signature
+
+    if (len < 3 || memcmp(data, "MUS", 3) != 0)
         return NULL;
     
 #ifdef _WIN32