Skip to content

Commit 5334339

Browse files
committed
Rewrite checking condition bufStart pointer NULL
1 parent 43de2aa commit 5334339

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

programs/util.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,11 @@ static int UTIL_prepareFileList(const char *dirName,
693693
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
694694
assert(newListSize >= 0);
695695
*bufStart = (char*)UTIL_realloc(*bufStart, (size_t)newListSize);
696-
*bufEnd = *bufStart + newListSize;
697-
if (*bufStart == NULL) { free(path); closedir(dir); return 0; }
696+
if (*bufStart != NULL) {
697+
*bufEnd = *bufStart + newListSize;
698+
} else {
699+
free(path); closedir(dir); return 0;
700+
}
698701
}
699702
if (*bufStart + *pos + pathLength < *bufEnd) {
700703
memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */

0 commit comments

Comments
 (0)