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

Summary: File pointer fp getting leak in load_instrument function
Product: SDL_mixer Reporter: Nitz <nitin.j4>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2    
Version: unspecified   
Hardware: x86   
OS: Linux   
Attachments: Patch for fp memory leak

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!