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
parent
12e5c2f07d
commit
1b2a2e6737
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue