diff options
author | dg <dg@FreeBSD.org> | 1995-01-28 01:58:14 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1995-01-28 01:58:14 +0000 |
commit | 7f0d63876d00885e81d4251e0cbacf3c6e686d3e (patch) | |
tree | cca036188be318876a9339d1940c9133bedb0f26 /usr.bin | |
parent | c0c281b7e320844342ec5b6b4717c1563e80c4e7 (diff) | |
download | FreeBSD-src-7f0d63876d00885e81d4251e0cbacf3c6e686d3e.zip FreeBSD-src-7f0d63876d00885e81d4251e0cbacf3c6e686d3e.tar.gz |
Fixed coredump when issuing d$ on a blank line. Fixes bin/191.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vi/common/delete.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/vi/common/delete.c b/usr.bin/vi/common/delete.c index a6d0a81..85eae5f 100644 --- a/usr.bin/vi/common/delete.c +++ b/usr.bin/vi/common/delete.c @@ -119,13 +119,15 @@ delete(sp, ep, fm, tm, lmode) GETLINE_ERR(sp, fm->lno); return (1); } - GET_SPACE_RET(sp, bp, blen, len); - if (fm->cno != 0) - memmove(bp, p, fm->cno); - memmove(bp + fm->cno, p + (tm->cno + 1), len - (tm->cno + 1)); - if (file_sline(sp, ep, fm->lno, - bp, len - ((tm->cno - fm->cno) + 1))) - goto err; + if (len != 0) { + GET_SPACE_RET(sp, bp, blen, len); + if (fm->cno != 0) + memmove(bp, p, fm->cno); + memmove(bp + fm->cno, p + (tm->cno + 1), len - (tm->cno + 1)); + if (file_sline(sp, ep, fm->lno, + bp, len - ((tm->cno - fm->cno) + 1))) + goto err; + } goto done; } |