Merge pull request #3304 from GermanAizek/dev

Rewrite check *bufStart condition
This commit is contained in:
Elliot Gorokhovsky 2022-11-01 12:45:42 -04:00 committed by GitHub
commit bb23f7b99b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -693,8 +693,11 @@ static int UTIL_prepareFileList(const char *dirName,
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE; ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
assert(newListSize >= 0); assert(newListSize >= 0);
*bufStart = (char*)UTIL_realloc(*bufStart, (size_t)newListSize); *bufStart = (char*)UTIL_realloc(*bufStart, (size_t)newListSize);
if (*bufStart != NULL) {
*bufEnd = *bufStart + newListSize; *bufEnd = *bufStart + newListSize;
if (*bufStart == NULL) { free(path); closedir(dir); return 0; } } else {
free(path); closedir(dir); return 0;
}
} }
if (*bufStart + *pos + pathLength < *bufEnd) { if (*bufStart + *pos + pathLength < *bufEnd) {
memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */ memcpy(*bufStart + *pos, path, pathLength + 1); /* with final \0 */