summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2017-06-24 16:30:48 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2017-06-24 16:30:48 +0000
commit740d96459c29b1315be404518bcf341c96b7c857 (patch)
tree7c0ed2128e4e5881ae3e082034a0091fb0e182ca /usr.bin/vi
parentb22143b23126a6371e438cafc66400b4d5e8d149 (diff)
Fix a check in ADD_SPACE_{GOTO,RET} that potentially allowed for a
NULL-dereference. OK tom@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/common/mem.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/vi/common/mem.h b/usr.bin/vi/common/mem.h
index f7eeedb977a..23b594b4f12 100644
--- a/usr.bin/vi/common/mem.h
+++ b/usr.bin/vi/common/mem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.h,v 1.9 2016/05/07 14:03:01 martijn Exp $ */
+/* $OpenBSD: mem.h,v 1.10 2017/06/24 16:30:47 martijn Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -79,7 +79,7 @@
*/
#define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \
+ if (L__gp != NULL && (bp) == L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
BINC_GOTO((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen));\
(bp) = L__gp->tmp_bp; \
@@ -90,7 +90,7 @@
}
#define ADD_SPACE_RET(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \
+ if (L__gp != NULL && (bp) == L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
BINC_RET((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen)); \
(bp) = L__gp->tmp_bp; \