pulse-server: don't leak formats

This commit is contained in:
Wim Taymans 2020-11-09 16:51:34 +01:00
parent a6c35d1df4
commit 99fcc95d18
3 changed files with 17 additions and 1 deletions

View file

@ -327,6 +327,13 @@ struct format_info {
struct pw_properties *props;
};
static void format_info_clear(struct format_info *info)
{
if (info->props)
pw_properties_free(info->props);
spa_zero(*info);
}
static int format_parse_param(const struct spa_pod *param, struct sample_spec *ss, struct channel_map *map)
{
struct spa_audio_info info = { 0 };

View file

@ -249,6 +249,7 @@ static int read_format_info(struct message *m, struct format_info *info)
int res;
uint8_t tag, encoding;
spa_zero(*info);
if ((res = read_u8(m, &tag)) < 0)
return res;
if (tag != TAG_U8)
@ -265,7 +266,9 @@ static int read_format_info(struct message *m, struct format_info *info)
info->props = pw_properties_new(NULL, NULL);
if (info->props == NULL)
return -errno;
return read_props(m, info->props);
if ((res = read_props(m, info->props)) < 0)
format_info_clear(info);
return res;
}
static int message_get(struct message *m, ...)

View file

@ -1542,6 +1542,7 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui
uint8_t i;
for (i = 0; i < n_formats; i++) {
struct format_info format;
if ((res = message_get(m,
TAG_FORMAT_INFO, &format,
TAG_INVALID)) < 0)
@ -1550,6 +1551,8 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui
if ((params[n_params] = format_info_build_param(&b,
SPA_PARAM_EnumFormat, &format)) != NULL)
n_params++;
format_info_clear(&format);
}
}
}
@ -1746,6 +1749,7 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint
uint8_t i;
for (i = 0; i < n_formats; i++) {
struct format_info format;
if ((res = message_get(m,
TAG_FORMAT_INFO, &format,
TAG_INVALID)) < 0)
@ -1754,6 +1758,8 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint
if ((params[n_params] = format_info_build_param(&b,
SPA_PARAM_EnumFormat, &format)) != NULL)
n_params++;
format_info_clear(&format);
}
}
if ((res = message_get(m,