]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Rewrite checking condition bufStart pointer NULL 3304/head
authorappleman4321 <GermanAizek@yandex.ru>
Mon, 31 Oct 2022 23:31:09 +0000 (02:31 +0300)
committerappleman4321 <GermanAizek@yandex.ru>
Mon, 31 Oct 2022 23:31:09 +0000 (02:31 +0300)
programs/util.c

index a3af262114365f3cf8767a27c27b00716cb10359..df0bb0afbc816728d07ffe3f202bf514691b5ebc 100644 (file)
@@ -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 */