[alsa-devel] memory leak in mix/pcm_upmix.c mix/pcm_downmix.c!!!

Takashi Iwai tiwai at suse.de
Wed Aug 30 10:32:15 CEST 2017


On Wed, 30 Aug 2017 10:28:35 +0200,
boozer asm wrote:
> 
> not sure what's the best place to call free.
> 1.
> static int snd_pcm_extplug_close(snd_pcm_t *pcm)
> {
>     extplug_priv_t *ext = pcm->private_data;
> 
>     snd_pcm_close(ext->plug.gen.slave);
>     clear_ext_params(ext);
>     if (ext->data->callback->close)
>     {
>         ext->data->callback->close(ext->data);
>     }
>     if (ext->data)
>          free(ext->data);
>     free(ext);
>     return 0;
> }
> 
> 2.
> 366 static int upmix_close(snd_pcm_extplug_t *ext)
> 367 {
> 368     snd_pcm_upmix_t *mix = (snd_pcm_upmix_t *)ext;
> 369     free(mix->delayline[0]);
> 370     free(mix->delayline[1]);
>           free(mix);
> 371     return 0;
> 372 }
> 
> 3. apply method in alsa-plugins/maemo/alsa-dsp.c:748:static void
> alsa_dsp_descructor(void) __attribute__ ((destructor));
> 
> with each methods, there are some plugins pcm_ files affected.

2 is the way to go.  1 may lead to double-free for the plugins that
have already the right code.  3 is too specific to implementation.


Takashi


More information about the Alsa-devel mailing list