diff decoders/timidity/timidity.c @ 411:1ba14a084531

Memory leak patched by Torbj�rn Andersson.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 17 Aug 2002 13:27:39 +0000
parents 3da217bd0e48
children cbc2a4ffeeec
line wrap: on
line diff
--- a/decoders/timidity/timidity.c	Mon Jul 29 22:37:04 2002 +0000
+++ b/decoders/timidity/timidity.c	Sat Aug 17 13:27:39 2002 +0000
@@ -306,10 +306,7 @@
       }
       if (bank->tone[i].name)
 	free(bank->tone[i].name);
-{
-printf("alloc name\n");
       strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]);
-}
       bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan=
       bank->tone[i].strip_loop=bank->tone[i].strip_envelope=
       bank->tone[i].strip_tail=-1;
@@ -574,7 +571,16 @@
     }
     if (master_drumset[i])
     {
-      free(master_drumset[i]->tone);
+      ToneBankElement *e = master_drumset[i]->tone;
+      if (e != NULL)
+      {
+        for (j = 0; j < 128; j++)
+        {
+          if (e[j].name != NULL)
+            free(e[j].name);
+        }
+        free(e);
+      }
       free(master_drumset[i]);
     }
   }