]> git.eshelyaron.com Git - emacs.git/commitdiff
(readline): Terminate buffer properly when EOF seen.
authorKarl Heuer <kwzh@gnu.org>
Sat, 14 Jun 1997 04:36:44 +0000 (04:36 +0000)
committerKarl Heuer <kwzh@gnu.org>
Sat, 14 Jun 1997 04:36:44 +0000 (04:36 +0000)
Test for valid pointer before dereferencing it.

lib-src/b2m.c

index 88d0acd5cd89549e328e2828e8f5bf2c7fb42e26..2eb6a0354b8863b554a127fd36631430b744bc53 100644 (file)
@@ -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;