fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[fluid-dev] fluidsynth-1.0.3 bug and solution


From: S.Pavlishin
Subject: [fluid-dev] fluidsynth-1.0.3 bug and solution
Date: Tue, 26 Aug 2003 17:09:58 +0700

Hello.
 
I'm compiled fluidsyth-1.0.3 on Win2kPro  VC6 SP5 + Platform SDK 2003.
Load most of my files causes to Access Violation in the  
fluid_midi_file_read_event(fluid_midi_file * 0x0098d110, _fluid_track_t * 
0x016030d8) line 476 + 9 bytes.
 
The problem is that my files has midi META events with zero len.
The solution is to check all META events before read them.
 
This is my patch.
 
---
Index: src/fluid_midi.c
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/src/fluid_midi.c,v
retrieving revision 1.2
diff -u -r1.2 fluid_midi.c
--- src/fluid_midi.c    3 Apr 2003 21:32:56 -0000       1.2
+++ src/fluid_midi.c    26 Aug 2003 09:48:33 -0000
@@ -343,6 +343,35 @@
}
 
/*
+ * fluid_midi_file_is_zerolen_meta
+ * return FLUID_FAILED if meta event should have non-zero len
+ */
+int fluid_midi_file_is_zerolen_meta(int meta_type){
+       switch(meta_type){
+       case 0x00:
+       case 0x01:
+       case 0x02:
+       case 0x03:
+       case 0x04:
+       case 0x05:
+       case 0x06:
+       case 0x07:
+       case 0x51:
+       case 0x58:
+       case 0x59:
+       case 0x7F:
+               return FLUID_FAILED;
+       case 0x2F:
+               return FLUID_OK;
+       };
+
+       /*
+        * return OK for unknown events
+        */
+       return FLUID_OK;
+}
+
+/*
 * fluid_midi_file_read_event
 */
int fluid_midi_file_read_event(fluid_midi_file* mf, fluid_track_t* track)
@@ -463,7 +492,18 @@
         }
         return FLUID_FAILED;
       }
-      }
+      } else  {
+               /*
+                * XXX
+                * a lot of midi files has wrong meta events with zero 
len data
+                * you should skip them
+                */
+               if(fluid_midi_file_is_zerolen_meta(type) != FLUID_OK){
+                       /* skip event
+                       */
+                       return FLUID_OK;
+               }
+         }
 
      /* handle meta data */
      switch (type) { 
---
 
 
 
Regards, 
Sergey Pavlishin.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]