mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: don't leak formats
This commit is contained in:
parent
a6c35d1df4
commit
99fcc95d18
3 changed files with 17 additions and 1 deletions
|
|
@ -327,6 +327,13 @@ struct format_info {
|
||||||
struct pw_properties *props;
|
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)
|
static int format_parse_param(const struct spa_pod *param, struct sample_spec *ss, struct channel_map *map)
|
||||||
{
|
{
|
||||||
struct spa_audio_info info = { 0 };
|
struct spa_audio_info info = { 0 };
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,7 @@ static int read_format_info(struct message *m, struct format_info *info)
|
||||||
int res;
|
int res;
|
||||||
uint8_t tag, encoding;
|
uint8_t tag, encoding;
|
||||||
|
|
||||||
|
spa_zero(*info);
|
||||||
if ((res = read_u8(m, &tag)) < 0)
|
if ((res = read_u8(m, &tag)) < 0)
|
||||||
return res;
|
return res;
|
||||||
if (tag != TAG_U8)
|
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);
|
info->props = pw_properties_new(NULL, NULL);
|
||||||
if (info->props == NULL)
|
if (info->props == NULL)
|
||||||
return -errno;
|
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, ...)
|
static int message_get(struct message *m, ...)
|
||||||
|
|
|
||||||
|
|
@ -1542,6 +1542,7 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for (i = 0; i < n_formats; i++) {
|
for (i = 0; i < n_formats; i++) {
|
||||||
struct format_info format;
|
struct format_info format;
|
||||||
|
|
||||||
if ((res = message_get(m,
|
if ((res = message_get(m,
|
||||||
TAG_FORMAT_INFO, &format,
|
TAG_FORMAT_INFO, &format,
|
||||||
TAG_INVALID)) < 0)
|
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,
|
if ((params[n_params] = format_info_build_param(&b,
|
||||||
SPA_PARAM_EnumFormat, &format)) != NULL)
|
SPA_PARAM_EnumFormat, &format)) != NULL)
|
||||||
n_params++;
|
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;
|
uint8_t i;
|
||||||
for (i = 0; i < n_formats; i++) {
|
for (i = 0; i < n_formats; i++) {
|
||||||
struct format_info format;
|
struct format_info format;
|
||||||
|
|
||||||
if ((res = message_get(m,
|
if ((res = message_get(m,
|
||||||
TAG_FORMAT_INFO, &format,
|
TAG_FORMAT_INFO, &format,
|
||||||
TAG_INVALID)) < 0)
|
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,
|
if ((params[n_params] = format_info_build_param(&b,
|
||||||
SPA_PARAM_EnumFormat, &format)) != NULL)
|
SPA_PARAM_EnumFormat, &format)) != NULL)
|
||||||
n_params++;
|
n_params++;
|
||||||
|
|
||||||
|
format_info_clear(&format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((res = message_get(m,
|
if ((res = message_get(m,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue