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 2314 - File pointer fp getting leak in load_instrument function
Summary: File pointer fp getting leak in load_instrument function
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86 Linux
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-18 08:37 UTC by Nitz
Modified: 2017-10-21 20:07 UTC (History)
0 users

See Also:


Attachments
Patch for fp memory leak (829 bytes, patch)
2015-05-06 05:43 UTC, Nitz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nitz 2013-12-18 08:37:21 UTC
File pointer *fp getting leak in load_instrument function at:
fail:
          ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Error reading sample %d", i);
          if (stereo_layer == 1)
             {
               for (j=0; j<i; j++)
                 free(ip->right_sample[j].data);
               free(ip->right_sample);
               i = ip->left_samples;
             }
          for (j=0; j<i; j++)
            free(ip->left_sample[j].data);
          free(ip->left_sample);
          free(ip);
          free(lp);
          return 0;

FIX for this issue:

Call close_file(fp); before return 0;
          free(ip->left_sample);
          free(ip);
          free(lp);
          close_file(fp);
          return 0;

Thanks...
Comment 1 Nitz 2015-05-06 05:43:40 UTC
Created attachment 2151 [details]
Patch for fp memory leak
Comment 2 Sam Lantinga 2017-10-21 20:07:59 UTC
The file code in instrum.c is now gone.

Thanks!