stream-restore: Fix use of uninitialized variable
authorGeorg Chini <georg@chini.tk>
Tue, 20 Apr 2021 10:18:43 +0000 (12:18 +0200)
committerGeorg Chini <georg@chini.tk>
Tue, 20 Apr 2021 10:18:43 +0000 (12:18 +0200)
The variable card_name in sink_input_preferred_sink_changed_cb and
source_output_preferred_source_changed_cb could be used uninitialized,
which leads to invalid database entries.

This patch fixes the problem.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/543>

src/modules/module-stream-restore.c

index baa35af..ff55871 100644 (file)
@@ -1594,7 +1594,7 @@ static void update_preferred_device(struct userdata *u, const char *name, const
 static pa_hook_result_t sink_input_preferred_sink_changed_cb(pa_core *c, pa_sink_input *sink_input, struct userdata *u) {
     char *name;
     pa_sink *sink;
-    const char *card_name;
+    const char *card_name = NULL;
 
     pa_assert(c);
     pa_assert(sink_input);
@@ -1723,7 +1723,7 @@ static pa_hook_result_t source_output_fixate_hook_callback(pa_core *c, pa_source
 static pa_hook_result_t source_output_preferred_source_changed_cb(pa_core *c, pa_source_output *source_output, struct userdata *u) {
     char *name;
     pa_source *source;
-    const char *card_name;
+    const char *card_name = NULL;
 
     pa_assert(c);
     pa_assert(source_output);