fix wrong NULL check after allocating executable directory

set_my_executable_path() checked my_executable_path instead of the freshly
allocated my_executable_directory, so a failed calloc led to strncpy on NULL.
Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 17:55:50 +07:00
1 parent e51bf90b63
commit 47df440998
1 file changed
+1 -1
+1 -1
View File
@@ -746,7 +746,7 @@ static void set_my_executable_path(void) {
if (wai_getExecutablePath(my_executable_path, path_length, &dirname_length) != -1) {
my_executable_path[path_length] = '\0';
my_executable_directory = (char *)calloc(dirname_length + 2, sizeof(uint8_t));
if (my_executable_path == NULL) {
if (my_executable_directory == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return;
}