mirror of
https://github.com/libfuse/libfuse.git
synced 2026-07-07 14:47:41 +08:00
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:
+8
-7
@@ -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:
|
||||
rmdir(mountpoint);
|
||||
free(mountpoint);
|
||||
out_free_args:
|
||||
out_free:
|
||||
if (mountpoint) {
|
||||
rmdir(mountpoint);
|
||||
free(mountpoint);
|
||||
}
|
||||
fuse_opt_free_args(&args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user