add malloc check to fix

master
Glenn K. Lockwood 2019-01-23 16:02:58 -08:00
parent 20bb99e1b7
commit 4c1c73ecae
1 changed files with 3 additions and 3 deletions

View File

@ -210,13 +210,13 @@ void parse_dirpath(char *dirpath_arg) {
}
tmp++;
}
// prevent changes to the original dirpath_arg
dirpath_arg = strdup(dirpath_arg);
filenames = (char **)malloc(path_count * sizeof(char **));
if (filenames == NULL) {
if (filenames == NULL || dirpath_arg == NULL) {
FAIL("out of memory");
}
// prevent changes to the original dirpath_arg
dirpath_arg = strdup(dirpath_arg);
token = strtok(dirpath_arg, delimiter_string);
while (token != NULL) {
filenames[i] = token;