spa: alsa: acp: fix memleak when destroying card profles

This commit is contained in:
Julian Bouzas 2021-07-07 13:27:53 -04:00
parent 33e07cc984
commit 2dcdc80030
4 changed files with 17 additions and 9 deletions

View file

@ -3780,7 +3780,7 @@ static void path_set_make_path_descriptions_unique(pa_alsa_path_set *ps) {
}
}
static void mapping_free(pa_alsa_mapping *m) {
void pa_alsa_mapping_free(pa_alsa_mapping *m) {
pa_assert(m);
pa_xfree(m->name);
@ -3810,7 +3810,7 @@ static void mapping_free(pa_alsa_mapping *m) {
pa_xfree(m);
}
static void profile_free(pa_alsa_profile *p) {
void pa_alsa_profile_free(pa_alsa_profile *p) {
pa_assert(p);
pa_xfree(p->name);
@ -4888,8 +4888,8 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
};
ps = pa_xnew0(pa_alsa_profile_set, 1);
ps->mappings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) mapping_free);
ps->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) profile_free);
ps->mappings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_mapping_free);
ps->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_profile_free);
ps->decibel_fixes = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) decibel_fix_free);
ps->input_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free);
ps->output_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free);

View file

@ -421,6 +421,8 @@ void pa_alsa_mapping_dump(pa_alsa_mapping *m);
void pa_alsa_profile_dump(pa_alsa_profile *p);
void pa_alsa_decibel_fix_dump(pa_alsa_decibel_fix *db_fix);
pa_alsa_mapping *pa_alsa_mapping_get(pa_alsa_profile_set *ps, const char *name);
void pa_alsa_mapping_free (pa_alsa_mapping *m);
void pa_alsa_profile_free (pa_alsa_profile *p);
pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel_map *bonus);
void pa_alsa_profile_set_probe(pa_alsa_profile_set *ps, pa_hashmap *mixers, const char *dev_id, const pa_sample_spec *ss, unsigned default_n_fragments, unsigned default_fragment_size_msec);

View file

@ -916,6 +916,8 @@ static void set_eld_devices(pa_hashmap *hash)
}
}
data->eld_device = eld_device;
if (data->eld_mixer_device_name)
pa_xfree(data->eld_mixer_device_name);
data->eld_mixer_device_name = pa_xstrdup(eld_mixer_device_name);
}
}
@ -1430,7 +1432,8 @@ static void ucm_add_mapping(pa_alsa_profile *p, pa_alsa_mapping *m) {
/* create empty path set for the future path additions */
ps = pa_xnew0(pa_alsa_path_set, 1);
ps->direction = m->direction;
ps->paths = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
ps->paths = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, pa_xfree,
(pa_free_cb_t) pa_alsa_path_free);
switch (m->direction) {
case PA_ALSA_DIRECTION_ANY:
@ -2032,8 +2035,10 @@ pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_cha
pa_alsa_profile_set *ps;
ps = pa_xnew0(pa_alsa_profile_set, 1);
ps->mappings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
ps->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
ps->mappings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
(pa_free_cb_t) pa_alsa_mapping_free);
ps->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
(pa_free_cb_t) pa_alsa_profile_free);
ps->decibel_fixes = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
/* create a profile for each verb */
@ -2296,8 +2301,7 @@ static void ucm_port_data_init(pa_alsa_ucm_port_data *port, pa_alsa_ucm_config *
device_add_ucm_port(devices[i], port);
}
port->paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, pa_xfree,
(pa_free_cb_t) pa_alsa_path_free);
port->paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, pa_xfree, NULL);
ucm_port_update_available(port);
}

View file

@ -153,6 +153,8 @@ void pa_device_port_free(pa_device_port *port)
pa_xfree(port->availability_group);
pa_hashmap_free(port->profiles);
pa_proplist_free(port->proplist);
if (port->impl_free)
port->impl_free (port);
free(port);
}