Possible fix for bug #3094 - use normal malloc/free for stuff that gets
[blender.git] / source / blender / blenkernel / intern / sound.c
index e4449ad0139af400d79b48586a9750fdbc103f73..6ced68fe83bbac4f3f1e7779592c008eda97bd5c 100644 (file)
@@ -28,12 +28,15 @@ ListBase _samples = {0,0}, *samples = &_samples;
 
 void sound_free_sound(bSound *sound)
 {
-       /* this crashes blender, PLEASE fix! */
-       // still crashes :(
-       //if (sound) {
-       //      sound_set_sample(sound, NULL);
-       //}
-       if (sound->stream) MEM_freeN(sound->stream);
+       /* when sounds have been loaded, but not played, the packedfile was not copied
+          to sample block and not freed otherwise */
+       if(sound->sample==NULL) {
+               if (sound->newpackedfile) {
+                       freePackedFile(sound->newpackedfile); 
+                       sound->newpackedfile = NULL;
+               }
+       }
+       if (sound->stream) free(sound->stream);
 }
 
 void sound_free_sample(bSample *sample)