Skip to content

Commit 8996f54

Browse files
add malloc check to fix
1 parent b561f60 commit 8996f54

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mdtest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ void parse_dirpath(char *dirpath_arg) {
206206
}
207207
tmp++;
208208
}
209+
// prevent changes to the original dirpath_arg
210+
dirpath_arg = strdup(dirpath_arg);
209211
filenames = (char **)malloc(path_count * sizeof(char **));
210-
if (filenames == NULL) {
212+
if (filenames == NULL || dirpath_arg == NULL) {
211213
FAIL("out of memory");
212214
}
213215

214-
// prevent changes to the original dirpath_arg
215-
dirpath_arg = strdup(dirpath_arg);
216216
token = strtok(dirpath_arg, delimiter_string);
217217
while (token != NULL) {
218218
filenames[i] = token;

0 commit comments

Comments
 (0)