Skip to content

Commit

Permalink
native_midi_common.c: backport two fixes from default (2.0) branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Oct 6, 2018
1 parent 7240a14 commit cfc135a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions native_midi/native_midi_common.c
Expand Up @@ -226,13 +226,15 @@ static MIDIEvent *MIDItoStream(MIDIFile *mididata)
MIDIEvent *currentEvent = head;
int trackID;

if (NULL == head)
return NULL;

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

return NULL;

track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
if (NULL == track)
{
free(head);
return NULL;
}
/* First, convert all tracks to MIDIEvent lists */
for (trackID = 0; trackID < mididata->nTracks; trackID++)
track[trackID] = MIDITracktoStream(&mididata->track[trackID]);
Expand Down Expand Up @@ -380,14 +382,18 @@ MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division)
*division = mididata->division;

eventList = MIDItoStream(mididata);

if (eventList == NULL)
{
free(mididata);
return NULL;
}
for(trackID = 0; trackID < mididata->nTracks; trackID++)
{
if (mididata->track[trackID].data)
free(mididata->track[trackID].data);
}
free(mididata->track);
free(mididata);
free(mididata);

return eventList;
}
Expand Down

0 comments on commit cfc135a

Please sign in to comment.