summaryrefslogtreecommitdiffstats
path: root/usr.bin/vi
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-01-28 01:58:14 +0000
committerdg <dg@FreeBSD.org>1995-01-28 01:58:14 +0000
commit7f0d63876d00885e81d4251e0cbacf3c6e686d3e (patch)
treecca036188be318876a9339d1940c9133bedb0f26 /usr.bin/vi
parentc0c281b7e320844342ec5b6b4717c1563e80c4e7 (diff)
downloadFreeBSD-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/vi')
-rw-r--r--usr.bin/vi/common/delete.c16
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;
}
OpenPOWER on IntegriCloud