test: Fix null-argument issue in test_signals.c

Check if mountpoint is NULL before calling rmdir() in the error
path. This fixes CodeChecker warning about use of NULL 'mountpoint'
where non-null expected.

Reported by: CodeChecker (gcc-null-argument)

Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
This commit is contained in:
Bernd Schubert
2026-04-04 21:52:38 +02:00
parent bdd9b96239
commit bb26f81a9e
+6 -5
View File
@@ -72,7 +72,7 @@ static void fork_child(void)
/* Add the program name to arg[0] */
if (fuse_opt_add_arg(&args, "test_signals")) {
fprintf(stderr, "Failed to add argument\n");
goto out_free_mountpoint;
goto out_free;
}
/* Add debug flag to see more output */
@@ -82,14 +82,14 @@ static void fork_child(void)
mountpoint = strdup("/tmp/fuse_test_XXXXXX");
if (!mountpoint || !mkdtemp(mountpoint)) {
fprintf(stderr, "Failed to create temp dir\n");
goto out_free_args;
goto out_free;
}
/* Create session */
se = fuse_session_new(&args, &test_ll_ops, sizeof(test_ll_ops), NULL);
if (!se) {
fprintf(stderr, "Failed to create FUSE session\n");
goto out_free_mountpoint;
goto out_free;
}
/* Mount filesystem */
@@ -155,10 +155,11 @@ out_unmount:
fuse_session_unmount(se);
out_destroy_session:
fuse_session_destroy(se);
out_free_mountpoint:
out_free:
if (mountpoint) {
rmdir(mountpoint);
free(mountpoint);
out_free_args:
}
fuse_opt_free_args(&args);
exit(1);
}