rcfile: fix an out-of-bounds read on empty lines

Signed-off-by: Saagar Jha <saagar@saagarjha.com>

Bug existed since commit 98f038ad from a week ago.
master
Saagar Jha 2020-02-16 04:04:11 -08:00 committed by Benno Schulenberg
parent 12e5c2f07d
commit 1b2a2e6737
1 changed files with 1 additions and 1 deletions

View File

@ -1320,7 +1320,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
/* Strip the terminating newline and possibly a carriage return. */
if (buffer[length - 1] == '\n')
buffer[--length] = '\0';
if (buffer[length - 1] == '\r')
if (length > 0 && buffer[length - 1] == '\r')
buffer[--length] = '\0';
ptr = buffer;