Fix: Dereference of null pointer in FOptiAttr
This commit is contained in:
parent
add402c5ac
commit
7d6d5cf71f
2
build.sh
2
build.sh
|
@ -9,7 +9,7 @@ case "$1" in
|
|||
;;
|
||||
|
||||
"--fulldebug"|"fulldebug")
|
||||
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy"
|
||||
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy"
|
||||
;;
|
||||
|
||||
"--profile"|"profile")
|
||||
|
|
|
@ -91,7 +91,7 @@ OBJS = \
|
|||
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")
|
||||
|
||||
ifdef DEBUG
|
||||
OPTIMIZE = -O0
|
||||
OPTIMIZE = -O0 -fsanitize=undefined
|
||||
else
|
||||
OPTIMIZE = -O2
|
||||
endif
|
||||
|
|
|
@ -83,6 +83,7 @@ inline bool FOptiAttr::colorChange (char_data*& term, char_data*& next)
|
|||
|| term->fg_color != next->fg_color
|
||||
|| term->bg_color != next->bg_color );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -199,12 +200,14 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
|
|||
char* Sf = F_set_foreground.cap;
|
||||
char* Sb = F_set_background.cap;
|
||||
char* sp = F_set_color_pair.cap;
|
||||
short fg = next->fg_color;
|
||||
short bg = next->bg_color;
|
||||
short fg, bg;
|
||||
|
||||
if ( monochron || ! term || ! next )
|
||||
return;
|
||||
|
||||
fg = next->fg_color;
|
||||
bg = next->bg_color;
|
||||
|
||||
if ( fg == Default || bg == Default )
|
||||
{
|
||||
if ( ansi_default_color )
|
||||
|
@ -313,9 +316,8 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::hasAttribute (char_data*& attr)
|
||||
{
|
||||
if ( ! attr )
|
||||
return false;
|
||||
|
||||
if ( attr )
|
||||
{
|
||||
return attr->bold == true
|
||||
|| attr->dim == true
|
||||
|| attr->italic == true
|
||||
|
@ -329,6 +331,9 @@ inline bool FOptiAttr::hasAttribute (char_data*& attr)
|
|||
|| attr->dbl_underline == true
|
||||
|| attr->alt_charset == true
|
||||
|| attr->pc_charset == true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -355,8 +360,11 @@ inline void FOptiAttr::resetAttribute (char_data*& attr)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::reset (char_data*& attr)
|
||||
{
|
||||
if ( attr )
|
||||
{
|
||||
resetAttribute(attr);
|
||||
resetColor(attr);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -915,8 +923,10 @@ short FOptiAttr::vga2ansi (register short color)
|
|||
0, 4, 2, 6, 1, 5, 3, 7,
|
||||
8, 12, 10, 14, 9, 13, 11, 15
|
||||
};
|
||||
|
||||
color = lookup_table[color];
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INCLUDES = -I../src
|
|||
RM = rm -f
|
||||
|
||||
ifdef DEBUG
|
||||
OPTIMIZE = -O0
|
||||
OPTIMIZE = -O0 -fsanitize=undefined
|
||||
else
|
||||
OPTIMIZE = -O2
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue