summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1998-05-15 21:35:53 +0000
committerache <ache@FreeBSD.org>1998-05-15 21:35:53 +0000
commitfd2f352d6a9d0f85908a776189dc6b616ff6087c (patch)
tree901604926b39a30d43085f37e251a571a10bbb3b
parent746b4b1f11fbf312cbec309324376ec7f4b948fc (diff)
downloadFreeBSD-src-fd2f352d6a9d0f85908a776189dc6b616ff6087c.zip
FreeBSD-src-fd2f352d6a9d0f85908a776189dc6b616ff6087c.tar.gz
Low level use of 'vidattr()' can cause a NULL pointer to be
dereferenced. This is because 'SP' is only initialized via 'newterm()' (which is not required if you are going to interact with the 'terminfo' database without using 'ncurses'). PR: 6648 Submitted by: Max Euston <meuston@jmrodgers.com>
-rw-r--r--lib/libncurses/lib_vidattr.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libncurses/lib_vidattr.c b/lib/libncurses/lib_vidattr.c
index 0bb5675..ef82139 100644
--- a/lib/libncurses/lib_vidattr.c
+++ b/lib/libncurses/lib_vidattr.c
@@ -71,13 +71,14 @@ int fg, bg;
}
}
-#define previous_attr SP->_current_attr
-
int vidputs(chtype newmode, int (*outc)(int))
{
-chtype turn_off = (~newmode & previous_attr) & ~A_COLOR;
-chtype turn_on = (newmode & ~previous_attr) & ~A_COLOR;
-int pair, current_pair;
+static chtype previous_attr=0;
+chtype turn_off,turn_on;
+int pair, current_pair;
+
+ if (SP)
+ previous_attr = SP->_current_attr;
T(("vidputs(%x) called %s", newmode, _traceattr(newmode)));
T(("previous attribute was %s", _traceattr(previous_attr)));
@@ -85,6 +86,9 @@ int pair, current_pair;
if (newmode == previous_attr)
return OK;
+ turn_off = (~newmode & previous_attr) & ~A_COLOR;
+ turn_on = (newmode & ~previous_attr) & ~A_COLOR;
+
pair = PAIR_NUMBER(newmode);
current_pair = PAIR_NUMBER(previous_attr);
@@ -184,6 +188,8 @@ int pair, current_pair;
}
previous_attr = newmode;
+ if (SP)
+ SP->_current_attr = previous_attr;
T(("vidputs finished"));
return OK;
OpenPOWER on IntegriCloud