handle open_memstream errors

Fixes #2182
This commit is contained in:
Wim Taymans 2022-03-02 11:48:31 +01:00
parent fdaf4613d8
commit 99f9f729ff
21 changed files with 70 additions and 21 deletions

View file

@ -4742,6 +4742,10 @@ static int profile_verify(pa_alsa_profile *p) {
int count = 0;
f = open_memstream(&ptr, &size);
if (f == NULL) {
pa_log("failed to open memstream: %m");
return -1;
}
if (p->output_mappings)
PA_IDXSET_FOREACH(m, p->output_mappings, idx) {
@ -4816,6 +4820,8 @@ void pa_alsa_decibel_fix_dump(pa_alsa_decibel_fix *db_fix) {
size_t size;
f = open_memstream(&ptr, &size);
if (f == NULL)
return;
pa_assert(db_fix->min_step <= db_fix->max_step);
nsteps = db_fix->max_step - db_fix->min_step + 1;

View file

@ -252,7 +252,9 @@ static int do_extension_stream_restore_write(struct client *client, uint32_t com
if (name == NULL || name[0] == '\0')
return -EPROTO;
f = open_memstream(&ptr, &size);
if ((f = open_memstream(&ptr, &size)) == NULL)
return -errno;
fprintf(f, "{");
fprintf(f, " \"mute\": %s", mute ? "true" : "false");
if (vol.channels > 0) {

View file

@ -619,7 +619,9 @@ static int add_int(struct format_info *info, const char *k, struct spa_pod *para
size_t size;
FILE *f;
f = open_memstream(&ptr, &size);
if ((f = open_memstream(&ptr, &size)) == NULL)
return -errno;
fprintf(f, "[");
for (i = 1; i < n_values; i++)
fprintf(f, "%s %d", i == 1 ? "" : ",", values[i]);

View file

@ -65,7 +65,7 @@ static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_man
r = open_memstream(response, &size);
if (r == NULL)
return -ENOMEM;
return -errno;
fputc('[', r);
for (i = 0; i < n_codecs; ++i) {
@ -100,7 +100,7 @@ static int core_object_message_handler(struct pw_manager *m, struct pw_manager_o
r = open_memstream(response, &size);
if (r == NULL)
return -ENOMEM;
return -errno;
fputc('[', r);
spa_list_for_each(o, &m->object_list, link) {

View file

@ -59,7 +59,9 @@ static int module_always_sink_load(struct client *client, struct module *module)
const char *str;
size_t size;
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
if ((str = pw_properties_get(module->props, "sink_name")) != NULL)
fprintf(f, " sink.name = \"%s\"", str);

View file

@ -72,7 +72,9 @@ static int module_echo_cancel_load(struct client *client, struct module *module)
char *args;
size_t size;
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
/* Can't just serialise this dict because the "null" method gets
* interpreted as a JSON null */

View file

@ -78,7 +78,9 @@ static int module_ladspa_sink_load(struct client *client, struct module *module)
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " filter.graph = {");

View file

@ -78,7 +78,9 @@ static int module_ladspa_source_load(struct client *client, struct module *modul
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " filter.graph = {");

View file

@ -75,7 +75,9 @@ static int module_loopback_load(struct client *client, struct module *module)
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
if (data->info.channels != 0) {
fprintf(f, " audio.channels = %u", data->info.channels);

View file

@ -72,7 +72,9 @@ static int module_remap_sink_load(struct client *client, struct module *module)
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " capture.props = {");

View file

@ -72,7 +72,9 @@ static int module_remap_source_load(struct client *client, struct module *module
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " capture.props = { ");

View file

@ -73,7 +73,9 @@ static int module_roc_sink_load(struct client *client, struct module *module)
pw_properties_setf(data->sink_props, "pulse.module.id",
"%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &data->roc_props->dict, 0);
fprintf(f, " } sink.props = {");

View file

@ -73,7 +73,9 @@ static int module_roc_source_load(struct client *client, struct module *module)
pw_properties_setf(data->source_props, "pulse.module.id",
"%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &data->roc_props->dict, 0);
fprintf(f, " } source.props = {");

View file

@ -68,7 +68,9 @@ static int module_simple_protocol_tcp_load(struct client *client, struct module
uint32_t i;
FILE *f;
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
if (data->info.rate != 0)
fprintf(f, " \"audio.rate\": %u,", data->info.rate);

View file

@ -76,7 +76,9 @@ static int module_tunnel_sink_load(struct client *client, struct module *module)
pw_properties_setf(data->stream_props, "pulse.module.id",
"%u", module->index);
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " pulse.server.address = \"%s\" ", server);

View file

@ -76,7 +76,9 @@ static int module_tunnel_source_load(struct client *client, struct module *modul
server = pw_properties_get(module->props, "server");
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " pulse.server.address = \"%s\" ", server);

View file

@ -59,7 +59,9 @@ static int module_x11_bell_load(struct client *client, struct module *module)
const char *str;
size_t size;
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL)
return -errno;
fprintf(f, "{");
if ((str = pw_properties_get(module->props, "sink")) != NULL)
fprintf(f, " sink.name = \"%s\"", str);

View file

@ -321,7 +321,11 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
}
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL) {
pw_log_error("Can't open memstream: %m");
goto done;
}
fprintf(f, "{");
pw_properties_serialize_dict(f, &props->dict, 0);
fprintf(f, " stream.props = {");

View file

@ -478,7 +478,8 @@ int pw_rtsp_client_send(struct pw_rtsp_client *client,
struct message *msg;
int cseq;
f = open_memstream((char**)&msg, &len);
if ((f = open_memstream((char**)&msg, &len)) == NULL)
return -errno;
fseek(f, sizeof(*msg), SEEK_SET);

View file

@ -329,7 +329,11 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
_("%s on %s"), desc, fqdn);
}
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL) {
pw_log_error("Can't open memstream: %m");
goto done;
}
fprintf(f, "{");
pw_properties_serialize_dict(f, &props->dict, 0);
fprintf(f, " stream.props = {");

View file

@ -202,7 +202,11 @@ int main(int argc, char *argv[])
}
f = open_memstream(&args, &size);
if ((f = open_memstream(&args, &size)) == NULL) {
fprintf(stderr, "can't open memstream: %m\n");
goto exit;
}
fprintf(f, "{");
if (opt_remote != NULL)