mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-06 06:46:29 -04:00
modules: handle allocation errors gracefully
This commit is contained in:
parent
24f9b9a335
commit
dd695ee5a7
6 changed files with 35 additions and 4 deletions
|
|
@ -2015,6 +2015,8 @@ static int port_set_peer_enum_format(void *object,
|
|||
if (formats) {
|
||||
uint32_t count = 0;
|
||||
port->peer_format_pod = spa_pod_copy(formats);
|
||||
if (port->peer_format_pod == NULL)
|
||||
return -errno;
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(subtypes); i++) {
|
||||
state = NULL;
|
||||
|
|
@ -2028,6 +2030,8 @@ static int port_set_peer_enum_format(void *object,
|
|||
}
|
||||
}
|
||||
port->peer_formats = calloc(count, sizeof(struct spa_pod *));
|
||||
if (port->peer_formats == NULL)
|
||||
return -errno;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(subtypes); i++) {
|
||||
state = NULL;
|
||||
while (spa_peer_param_parse(port->peer_format_pod, &info, sizeof(info), &state) > 0) {
|
||||
|
|
|
|||
|
|
@ -931,6 +931,8 @@ static int create_stream(struct stream_info *info)
|
|||
|
||||
if (info->on_demand_id) {
|
||||
s->on_demand_id = strdup(info->on_demand_id);
|
||||
if (s->on_demand_id == NULL)
|
||||
goto error_errno;
|
||||
pw_properties_set(info->stream_props, "combine.on-demand-id", s->on_demand_id);
|
||||
} else {
|
||||
if (pw_properties_get(info->stream_props, PW_KEY_TARGET_OBJECT) == NULL)
|
||||
|
|
|
|||
|
|
@ -1410,7 +1410,10 @@ static void parse_devices(struct impl *impl, const char *val, size_t len)
|
|||
impl->n_devices = 0;
|
||||
while (spa_json_get_string(&it[0], v, sizeof(v)) > 0 &&
|
||||
impl->n_devices < FFADO_MAX_SPECSTRINGS) {
|
||||
impl->devices[impl->n_devices++] = strdup(v);
|
||||
char *s = strdup(v);
|
||||
if (s == NULL)
|
||||
return;
|
||||
impl->devices[impl->n_devices++] = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1532,6 +1532,8 @@ static int parse_sdp_m(struct impl *impl, char *c, struct sdp_info *info)
|
|||
return -EINVAL;
|
||||
|
||||
info->media_type = strdup(media_type);
|
||||
if (info->media_type == NULL)
|
||||
return -errno;
|
||||
info->dst_port = (uint16_t) port;
|
||||
info->payload = (uint8_t) payload;
|
||||
|
||||
|
|
@ -1583,6 +1585,8 @@ static int parse_sdp_a_rtpmap(struct impl *impl, char *c, struct sdp_info *info)
|
|||
c += len;
|
||||
c[strcspn(c, "/")] = 0;
|
||||
info->mime_type = strdup(c);
|
||||
if (info->mime_type == NULL)
|
||||
return -errno;
|
||||
c += strlen(c) + 1;
|
||||
|
||||
if (sscanf(c, "%u/%u", &rate, &channels) == 2) {
|
||||
|
|
@ -1647,6 +1651,8 @@ static int parse_sdp_a_ts_refclk(struct impl *impl, char *c, struct sdp_info *in
|
|||
|
||||
c += strlen("a=ts-refclk:");
|
||||
info->ts_refclk = strdup(c);
|
||||
if (info->ts_refclk == NULL)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1668,11 +1674,15 @@ static int parse_sdp(struct impl *impl, char *sdp, struct sdp_info *info)
|
|||
if (count++ == 0 && strcmp(s, "v=0") != 0)
|
||||
goto invalid_version;
|
||||
|
||||
if (spa_strstartswith(s, "o="))
|
||||
if (spa_strstartswith(s, "o=")) {
|
||||
info->origin = strdup(&s[2]);
|
||||
else if (spa_strstartswith(s, "s="))
|
||||
if (info->origin == NULL)
|
||||
res = -errno;
|
||||
} else if (spa_strstartswith(s, "s=")) {
|
||||
info->session_name = strdup(&s[2]);
|
||||
else if (spa_strstartswith(s, "c="))
|
||||
if (info->session_name == NULL)
|
||||
res = -errno;
|
||||
} else if (spa_strstartswith(s, "c="))
|
||||
res = parse_sdp_c(impl, s, info);
|
||||
else if (spa_strstartswith(s, "m="))
|
||||
res = parse_sdp_m(impl, s, info);
|
||||
|
|
|
|||
|
|
@ -622,6 +622,12 @@ static struct session *make_session(struct impl *impl, struct service_info *info
|
|||
str = pw_properties_get(props, "sess.name");
|
||||
sess->name = str ? strdup(str) : strdup("RTP Session");
|
||||
|
||||
if (sess->info.name == NULL || sess->info.type == NULL ||
|
||||
sess->info.domain == NULL || sess->name == NULL) {
|
||||
free_session(sess);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (impl->ts_refclk != NULL)
|
||||
pw_properties_setf(props, "rtp.sender-ts-offset", "%u", impl->ts_offset);
|
||||
pw_properties_setf(props, "rtp.sender-ssrc", "%u", sess->ssrc);
|
||||
|
|
|
|||
|
|
@ -497,6 +497,8 @@ static int add_snapcast_stream(struct impl *impl, struct tunnel *t,
|
|||
|
||||
while (spa_json_get_string(&it[0], v, sizeof(v)) > 0) {
|
||||
t->server_address = strdup(v);
|
||||
if (t->server_address == NULL)
|
||||
return -errno;
|
||||
snapcast_connect(t);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -544,6 +546,8 @@ static int create_stream(struct impl *impl, struct pw_properties *props,
|
|||
if ((str = pw_properties_get(props, "snapcast.stream-name")) == NULL)
|
||||
str = "PipeWire";
|
||||
t->stream_name = strdup(str);
|
||||
if (t->stream_name == NULL)
|
||||
return -errno;
|
||||
|
||||
if ((str = pw_properties_get(props, "capture")) == NULL)
|
||||
pw_properties_set(props, "capture", "true");
|
||||
|
|
@ -662,6 +666,8 @@ static void on_zeroconf_added(void *data, const void *user, const struct spa_dic
|
|||
|
||||
free((char*)t->info.host);
|
||||
t->info.host = strdup(pw_properties_get(props, "snapcast.ip"));
|
||||
if (t->info.host == NULL)
|
||||
return;
|
||||
|
||||
family = protocol == 4 ? AF_INET : AF_INET6;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue