From: appleman4321 Date: Mon, 31 Oct 2022 23:31:09 +0000 (+0300) Subject: Rewrite checking condition bufStart pointer NULL X-Git-Tag: v1.5.4^2~135^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=533433942134bdf1016eebfcc205012e66d6537c;p=thirdparty%2Fzstd.git Rewrite checking condition bufStart pointer NULL --- diff --git a/programs/util.c b/programs/util.c index a3af26211..df0bb0afb 100644 --- a/programs/util.c +++ b/programs/util.c @@ -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 */