mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-26 21:38:23 -04:00
treewide: add error checking to spa_json_builder_close
There could have been a write error or allocation error while building the json file that we can detect in spa_json_builder_close(). Error out instead of silently using a truncated JSON. Use spa_autofree for the memory to make cleanup easier.
This commit is contained in:
parent
6d1c242433
commit
4f975d0071
41 changed files with 240 additions and 194 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <spa/utils/cleanup.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/string.h>
|
||||
#include <spa/utils/json-builder.h>
|
||||
|
|
@ -243,7 +244,7 @@ static void on_zeroconf_added(void *data, const void *user_data, const struct sp
|
|||
struct tunnel_info tinfo;
|
||||
const struct spa_dict_item *it;
|
||||
struct spa_json_builder b;
|
||||
char *args;
|
||||
spa_autofree char *args = NULL;
|
||||
size_t size;
|
||||
struct pw_impl_module *mod;
|
||||
struct pw_properties *props = NULL;
|
||||
|
|
@ -337,13 +338,13 @@ static void on_zeroconf_added(void *data, const void *user_data, const struct sp
|
|||
spa_json_builder_object_push(&b, "stream.props", "{");
|
||||
spa_json_builder_pop(&b, "}");
|
||||
spa_json_builder_pop(&b, "}");
|
||||
spa_json_builder_close(&b);
|
||||
if (spa_json_builder_close(&b) < 0)
|
||||
goto done;
|
||||
|
||||
pw_log_info("loading module args:'%s'", args);
|
||||
mod = pw_context_load_module(impl->context,
|
||||
"libpipewire-module-pulse-tunnel",
|
||||
args, NULL);
|
||||
free(args);
|
||||
|
||||
if (mod == NULL) {
|
||||
pw_log_error("Can't load module: %m");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue