Skip to contentSkip to conversation

Small memory leak in snd_pcm_ladspa_init()

DISCUSSION John Lindgren 2 participants 3 messages Jul 21, 2010 – Jul 22, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

Valgrind shows up a small memory leak in libasound when using a LADSPA plugin. Sorry, I don't have a patch this time.

==30783== 16 bytes in 2 blocks are definitely lost in loss record 1,976 of 6,954

==30783==    at 0x4C2380C: calloc (vg_replace_malloc.c:467)
==30783==    by 0x1B06BEFD: snd_pcm_ladspa_init (pcm_ladspa.c:744)
==30783==    by 0x1B04B325: snd_pcm_plugin_prepare (pcm_plugin.c:167)
==30783==    by 0x1B04B2EE: snd_pcm_plugin_prepare (pcm_plugin.c:158)

==30783== 16 bytes in 2 blocks are definitely lost in loss record 1,977 of 6,954

==30783==    at 0x4C2380C: calloc (vg_replace_malloc.c:467)
==30783==    by 0x1B06BF25: snd_pcm_ladspa_init (pcm_ladspa.c:746)
==30783==    by 0x1B04B325: snd_pcm_plugin_prepare (pcm_plugin.c:167)
==30783==    by 0x1B04B2EE: snd_pcm_plugin_prepare (pcm_plugin.c:158)

...

==30783== 16 bytes in 2 blocks are definitely lost in loss record 1,980 of 6,954

==30783==    at 0x4C2380C: calloc (vg_replace_malloc.c:467)
==30783==    by 0x1B06BEFD: snd_pcm_ladspa_init (pcm_ladspa.c:744)
==30783==    by 0x1B04B325: snd_pcm_plugin_prepare (pcm_plugin.c:167)
==30783==    by 0x1B04B2EE: snd_pcm_plugin_prepare (pcm_plugin.c:158)
==30783==    by 0x1B03B2DC: snd_pcm_recover (pcm.c:7246)

==30783== 16 bytes in 2 blocks are definitely lost in loss record 1,981 of 6,954

==30783==    at 0x4C2380C: calloc (vg_replace_malloc.c:467)
==30783==    by 0x1B06BF25: snd_pcm_ladspa_init (pcm_ladspa.c:746)
==30783==    by 0x1B04B325: snd_pcm_plugin_prepare (pcm_plugin.c:167)
==30783==    by 0x1B04B2EE: snd_pcm_plugin_prepare (pcm_plugin.c:158)
==30783==    by 0x1B03B2DC: snd_pcm_recover (pcm.c:7246)

... and so on.

-- John

#1 lore raw
Quoted 4 lines · John Lindgren

Hello,

Valgrind shows up a small memory leak in libasound when using a LADSPA plugin. Sorry, I don't have a patch this time.

Does this patch help?

src/pcm/pcm_ladspa.c +2 -0
index 5161820..c413c10 100644
@@ -341,6 +341,8 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
  						free(instance->output.m_data[idx]);
  					free(instance->output.m_data);
                                  }
+                                free(instance->input.data);
+                                free(instance->output.data);
  				list_del(&(instance->list));
  				snd_pcm_ladspa_free_eps(&instance->input);
  				snd_pcm_ladspa_free_eps(&instance->output);

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

#2 lore raw

Yes, that fixes it. Thank you.

-- John

Quoted 21 lines · Jaroslav Kysela

Does this patch help?

src/pcm/pcm_ladspa.c +2 -1
index 5161820..c413c10 100644
@@ -341,6 +341,8 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
  						free(instance->output.m_data[idx]);
  					free(instance->output.m_data);
                                  }
+                                free(instance->input.data);
+                                free(instance->output.data);
  				list_del(&(instance->list));
  				snd_pcm_ladspa_free_eps(&instance->input);
  				snd_pcm_ladspa_free_eps(&instance->output);
 
-----

Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.