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 672 - _EFF_PositionDeinit doesn't free memory correctly and can only be called once
Summary: _EFF_PositionDeinit doesn't free memory correctly and can only be called once
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 1.2.8
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-07 05:14 UTC by Luke Kenneth Casson Leighton
Modified: 2009-01-07 12:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Kenneth Casson Leighton 2009-01-07 05:14:55 UTC
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510971

the developer of d2x-xl has tracked down a problem with _Eff_PositionDeinit
and has fixed it with the following code:

void _Eff_PositionDeinit(void)
{
    int i;

     if (pos_args_array) {
        for (i = 0; i < position_channels; i++)
            if (pos_args_array[i])
              free(pos_args_array[i]);
        free(pos_args_array);
         pos_args_array = NULL;
        }
     position_channels = 0;
     if (pos_args_global) {
        free(pos_args_global);
        pos_args_global = NULL;
        }
}

Debian patches the same function but the patch method is not as robust
as the above code from the d2x-xl developer.  as you can see, everything
is re-initialised so that the library can be used again.

he d2x-xl developer is having to advise people to install a custom-built
version of libsdl-mixer due to this bug!
Comment 1 Ryan C. Gordon 2009-01-07 12:53:54 UTC
The current code in Subversion looks like this...

void _Eff_PositionDeinit(void)
{
    int i;
    for (i = 0; i < position_channels; i++) {
        free(pos_args_array[i]);
    }

    position_channels = 0;

    free(pos_args_global);
    pos_args_global = NULL;
    free(pos_args_array);
    pos_args_array = NULL;
}

...it should give the same results.

The latest change was the addition of "position_channels = 0;" 11 months ago, but we haven't released an SDL_mixer 1.2.9 with the change.

--ryan.