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 - Duplicated code in MIDItoStream()
Summary: Duplicated code in MIDItoStream()
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-13 18:42 UTC by manuel.montezelo
Modified: 2013-09-28 17:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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