vi: fix adjustment of buffer on partial file read
authorRon Yorston <rmy@tigress.co.uk>
Thu, 7 Mar 2013 20:37:23 +0000 (20:37 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 15 Mar 2013 01:10:07 +0000 (02:10 +0100)
The second argument to text_hole_delete was incorrect: it should
be a pointer to the end of the hole.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/vi.c

index 7173415c888484b992eb343cb4f4b756f6d216db..3d6182bbf853c252fa43a39c06d4d721fea26a31 100644 (file)
@@ -2530,7 +2530,7 @@ static int file_insert(const char *fn, char *p, int update_ro_status)
                p = text_hole_delete(p, p + size - 1);  // un-do buffer insert
        } else if (cnt < size) {
                // There was a partial read, shrink unused space text[]
-               p = text_hole_delete(p + cnt, p + (size - cnt) - 1);    // un-do buffer insert
+               p = text_hole_delete(p + cnt, p + size - 1);    // un-do buffer insert
                status_line_bold("can't read '%s'", fn);
        }
        if (cnt >= size)