From c7519c73ac515680caef9dcafa07f11e81b747b8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 10 Jan 2024 11:34:27 +0100 Subject: [PATCH] spa: small cleanups Use snprint to ensure null terminated strings. Initialize res, it would be uninitialized when setting a NULL Latency param. --- spa/plugins/alsa/alsa-pcm.c | 3 ++- spa/plugins/alsa/alsa-seq-bridge.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 13c1bbe61..c6da1dd5a 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -776,7 +776,8 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) while (spa_json_get_string(&it[1], v, sizeof(v)) > 0 && i < SPA_N_ELEMENTS(state->bound_ctls)) { - strncpy(state->bound_ctls[i].name, v, sizeof(state->bound_ctls[i].name)); + snprintf(state->bound_ctls[i].name, + sizeof(state->bound_ctls[i].name), "%s", v); i++; } state->num_bind_ctls = i; diff --git a/spa/plugins/alsa/alsa-seq-bridge.c b/spa/plugins/alsa/alsa-seq-bridge.c index 01f3eb322..310312c47 100644 --- a/spa/plugins/alsa/alsa-seq-bridge.c +++ b/spa/plugins/alsa/alsa-seq-bridge.c @@ -677,7 +677,7 @@ impl_node_port_set_param(void *object, { struct seq_state *this = object; struct seq_port *port; - int res; + int res = 0; spa_return_val_if_fail(this != NULL, -EINVAL);