Commit 5326c1d6 authored by Karl Heuer's avatar Karl Heuer
Browse files

(readline): Terminate buffer properly when EOF seen.

Test for valid pointer before dereferencing it.
parent 12e36cdb
......@@ -211,12 +211,13 @@ readline (linebuffer, stream)
}
if (c == EOF)
{
*p = '\0';
chars_deleted = 0;
break;
}
if (c == '\n')
{
if (p[-1] == '\r' && p > buffer)
if (p > buffer && p[-1] == '\r')
{
*--p = '\0';
chars_deleted = 2;
......
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