We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2099

Summary: Duplicated code in MIDItoStream()
Product: SDL_mixer Reporter: manuel.montezelo
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann
Version: unspecified   
Hardware: All   
OS: All   

Description manuel.montezelo 2013-09-13 18:42:15 UTC
Hi,

I believe that lines 233-234 are duplicated from 229-230, in
http://hg.libsdl.org/SDL_mixer/file/4641ef4c0fa6/native_midi/native_midi_common.c

The lines:
if (NULL == head)
  return NULL;

Those lines being after initializing head to a dummy value I think that it cannot ever be null, but it's a reasonable sanity check.

Hope that helps.
Comment 1 Sam Lantinga 2013-09-28 06:58:14 UTC
Yup, they are indeed duplicated. Thanks!
http://hg.libsdl.org/SDL_mixer/rev/52764006cd23
Comment 2 Philipp Wiesemann 2013-09-28 10:28:47 UTC
I think there was a typo in the second (now removed) check, It should have checked the return value of calloc().

track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
if (NULL == track)
  return NULL;

All other return values of calloc() in this file are checked for being not 0.
Comment 3 Sam Lantinga 2013-09-28 17:35:04 UTC
Oh, good point.  This is fixed.
http://hg.libsdl.org/SDL_mixer/rev/8a04342cf1e1