Skip to content

Commit 8409b1b

Browse files
this time
1 parent c580e89 commit 8409b1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

code/logic/syscall.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
#define PATH_SEP '/'
3535
#endif
3636

37+
static char *custom_strdup(const char *s) {
38+
if (!s) return NULL;
39+
size_t len = strlen(s) + 1;
40+
char *copy = (char *)malloc(len);
41+
if (copy) {
42+
memcpy(copy, s, len);
43+
}
44+
return copy;
45+
}
3746

3847
/*
3948
* Function to execute a system command.
@@ -256,7 +265,7 @@ int fossil_sys_call_list_directory(const char *dirname, char ***out_list, size_t
256265
}
257266
*out_list = tmp;
258267
}
259-
(*out_list)[*out_count] = _strdup(find_data.cFileName);
268+
(*out_list)[*out_count] = custom_strdup(find_data.cFileName);
260269
(*out_count)++;
261270
}
262271
} while (FindNextFile(hFind, &find_data));
@@ -286,7 +295,7 @@ int fossil_sys_call_list_directory(const char *dirname, char ***out_list, size_t
286295
}
287296
*out_list = tmp;
288297
}
289-
(*out_list)[*out_count] = strdup(entry->d_name);
298+
(*out_list)[*out_count] = custom_strdup(entry->d_name);
290299
(*out_count)++;
291300
}
292301
}

0 commit comments

Comments
 (0)