From e6316eb4d88d97df765e91b1ce1cbc3b48232980 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Tue, 15 Apr 2014 09:46:27 -0400 Subject: [PATCH] Encompass all the _colorTable in the check for null Possible dereference after null - move the if() to include all checks --- src/TerminalCharacterDecoder.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/TerminalCharacterDecoder.cpp b/src/TerminalCharacterDecoder.cpp index 3c735419..d606dc2d 100644 --- a/src/TerminalCharacterDecoder.cpp +++ b/src/TerminalCharacterDecoder.cpp @@ -210,20 +210,21 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP QString style; bool useBold; - ColorEntry::FontWeight weight = characters[i].fontWeight(_colorTable); - if (weight == ColorEntry::UseCurrentFormat) - useBold = _lastRendition & RE_BOLD; - else - useBold = weight == ColorEntry::Bold; - - if (useBold) - style.append("font-weight:bold;"); - - if (_lastRendition & RE_UNDERLINE) - style.append("font-decoration:underline;"); //colors - a color table must have been defined first if (_colorTable) { + ColorEntry::FontWeight weight = characters[i].fontWeight(_colorTable); + if (weight == ColorEntry::UseCurrentFormat) + useBold = _lastRendition & RE_BOLD; + else + useBold = weight == ColorEntry::Bold; + + if (useBold) + style.append("font-weight:bold;"); + + if (_lastRendition & RE_UNDERLINE) + style.append("font-decoration:underline;"); + style.append(QString("color:%1;").arg(_lastForeColor.color(_colorTable).name())); style.append(QString("background-color:%1;").arg(_lastBackColor.color(_colorTable).name()));