Skip to content

Commit

Permalink
Merge pull request #3304 from GermanAizek/dev
Browse files Browse the repository at this point in the history
Rewrite check *bufStart condition
  • Loading branch information
embg authored Nov 1, 2022
2 parents 43de2aa + 5334339 commit bb23f7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,11 @@ static int UTIL_prepareFileList(const char *dirName,
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
assert(newListSize >= 0);
*bufStart = (char*)UTIL_realloc(*bufStart, (size_t)newListSize);
*bufEnd = *bufStart + newListSize;
if (*bufStart == NULL) { free(path); closedir(dir); return 0; }
if (*bufStart != NULL) {
*bufEnd = *bufStart + newListSize;
} else {
free(path); closedir(dir); return 0;
}
}
if (*bufStart + *pos + pathLength < *bufEnd) {
memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */
Expand Down

0 comments on commit bb23f7b

Please sign in to comment.