Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_EFF_PositionDeinit doesn't free memory correctly and can only be called once #55

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.8
Reported for operating system, platform: Linux, x86

Comments on the original bug report:

On 2009-01-07 05:14:55 +0000, Luke Kenneth Casson Leighton wrote:

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!

On 2009-01-07 12:53:54 +0000, Ryan C. Gordon wrote:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant