summaryrefslogtreecommitdiffstats
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1996-03-03 15:47:43 +0000
committerwosch <wosch@FreeBSD.org>1996-03-03 15:47:43 +0000
commitba6dcbd08e7b3b6aac5339cf18a083093731ff07 (patch)
tree96ea1151e292b964db32faa6cc5ddaafeb1eb2ee /usr.bin/vi
parent1aa447c3b2fe9d98cdd17baf61f545386df1aa62 (diff)
downloadFreeBSD-src-ba6dcbd08e7b3b6aac5339cf18a083093731ff07.zip
FreeBSD-src-ba6dcbd08e7b3b6aac5339cf18a083093731ff07.tar.gz
``~a'', ``~i'' etc. cause vi to core dump
if the (file)buffer is empty (line=1, colum=0, len=0) Submitted by: batie@agora.rdrop.com (Alan Batie)
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/vi/v_ulcase.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/vi/vi/v_ulcase.c b/usr.bin/vi/vi/v_ulcase.c
index 959fdbb..684a7f5 100644
--- a/usr.bin/vi/vi/v_ulcase.c
+++ b/usr.bin/vi/vi/v_ulcase.c
@@ -84,6 +84,7 @@ v_ulcase(sp, ep, vp)
u_long cnt;
char *p;
+ len = 0;
lno = vp->m_start.lno;
cno = vp->m_start.cno;
@@ -120,7 +121,10 @@ v_ulcase(sp, ep, vp)
/* Check to see if we tried to move past EOF. */
if (file_gline(sp, ep, vp->m_final.lno, &len) == NULL) {
- (void)file_gline(sp, ep, --vp->m_final.lno, &len);
+ /* line number start with 1, lno zero is illegal */
+ if (vp->m_final.lno > 1)
+ --vp->m_final.lno;
+ (void)file_gline(sp, ep, vp->m_final.lno, &len);
vp->m_final.cno = len == 0 ? 0 : len - 1;
}
return (0);
OpenPOWER on IntegriCloud