diff mbox series

[BlueZ,06/15] test-runner: Fix uninitialised variable usage

Message ID 20240516090340.61417-7-hadess@hadess.net
State New
Headers show
Series Fix a number of static analysis issues #2 | expand

Commit Message

Bastien Nocera May 16, 2024, 9:03 a.m. UTC
Error: UNINIT (CWE-457): [#def72] [important]
bluez-5.75/tools/test-runner.c:856:2: var_decl: Declaring variable "argv" without initializer.
bluez-5.75/tools/test-runner.c:945:2: uninit_use: Using uninitialized value "argv[0]".
943|   	envp[pos] = NULL;
944|
945|-> 	printf("Running command %s\n", cmdname ? cmdname : argv[0]);
946|
947|   	pid = fork();
---
 tools/test-runner.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/tools/test-runner.c b/tools/test-runner.c
index 134e26f9c691..ff5e19825801 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -912,6 +912,11 @@  static void run_command(char *cmdname, char *home)
 		audio_pid[0] = audio_pid[1] = -1;
 
 start_next:
+	if (!run_auto && !cmdname) {
+		fprintf(stderr, "Missing command argument\n");
+		return;
+	}
+
 	if (run_auto) {
 		if (chdir(home + 5) < 0) {
 			perror("Failed to change home test directory");