mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-19 21:37:36 -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
|
|
@ -19,6 +19,7 @@
|
|||
#include <net/if.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#include <spa/utils/cleanup.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/string.h>
|
||||
#include <spa/utils/json-builder.h>
|
||||
|
|
@ -533,7 +534,7 @@ static int create_stream(struct impl *impl, struct pw_properties *props,
|
|||
struct tunnel *t)
|
||||
{
|
||||
struct spa_json_builder b;
|
||||
char *args;
|
||||
spa_autofree char *args = NULL;
|
||||
size_t size;
|
||||
int res = 0;
|
||||
struct pw_impl_module *mod;
|
||||
|
|
@ -567,13 +568,13 @@ static int create_stream(struct impl *impl, struct pw_properties *props,
|
|||
spa_json_builder_array_push(&b, "{");
|
||||
pw_properties_serialize_dict(b.f, &props->dict, 0);
|
||||
spa_json_builder_pop(&b, "}");
|
||||
spa_json_builder_close(&b);
|
||||
if ((res = 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-protocol-simple",
|
||||
args, NULL);
|
||||
free(args);
|
||||
|
||||
if (mod == NULL) {
|
||||
res = -errno;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue