fix: return empty string instead of null on glob failure in directory glob
The tool_function_directory_glob function previously returned NULL when the glob pattern failed to match, causing a null pointer dereference in the user profile avatar loader when it attempted to process the result. Changed the return value to an empty string to ensure callers always receive a valid pointer.
This commit is contained in:
parent
6d84cbef32
commit
6b08d3334c
2
tools.h
2
tools.h
@ -425,7 +425,7 @@ char* tool_function_directory_glob(char* target_dir) {
|
|||||||
|
|
||||||
if (glob(target_dir, GLOB_TILDE, NULL, &results) != 0) {
|
if (glob(target_dir, GLOB_TILDE, NULL, &results) != 0) {
|
||||||
perror("glob failed");
|
perror("glob failed");
|
||||||
return NULL;
|
return strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object* json_array = json_object_new_array();
|
json_object* json_array = json_object_new_array();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user