We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 43de2aa commit 5334339Copy full SHA for 5334339
programs/util.c
@@ -693,8 +693,11 @@ static int UTIL_prepareFileList(const char *dirName,
693
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
694
assert(newListSize >= 0);
695
*bufStart = (char*)UTIL_realloc(*bufStart, (size_t)newListSize);
696
- *bufEnd = *bufStart + newListSize;
697
- if (*bufStart == NULL) { free(path); closedir(dir); return 0; }
+ if (*bufStart != NULL) {
+ *bufEnd = *bufStart + newListSize;
698
+ } else {
699
+ free(path); closedir(dir); return 0;
700
+ }
701
}
702
if (*bufStart + *pos + pathLength < *bufEnd) {
703
memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */
0 commit comments