Commit 36e066df authored by Jan Rybar's avatar Jan Rybar Committed by Craig Small

Possible segfault in file2strvec introduced by latest CVE fix

'rbuf' used before allocated.
Revealed by static analysis
parent c6a6b1ca
......@@ -720,7 +720,7 @@ static char** file2strvec(const char* directory, const char* what) {
#undef ARG_LEN
if (end_of_file &&
((n > 0 && buf[n-1] != '\0') || /* last read char not null */
(n <= 0 && rbuf[tot-1] != '\0'))) /* last read char not null */
(n <= 0 && rbuf && rbuf[tot-1] != '\0'))) /* last read char not null */
buf[n++] = '\0'; /* so append null-terminator */
if (n <= 0) break; /* unneeded (end_of_file = 1) but avoid realloc */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment