From 9e46fbb4f9c42be7d538d4d58af81bdaf8ea1a22 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 27 May 2018 22:58:22 +0200 Subject: [PATCH] Fixed dereferenced null pointer --- include/final/fterm.h | 1 + src/fterm.cpp | 20 +++++++++++++++++--- src/test/fstring-test.cpp | 12 ------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/final/fterm.h b/include/final/fterm.h index 98b9751c..db745ac7 100644 --- a/include/final/fterm.h +++ b/include/final/fterm.h @@ -443,6 +443,7 @@ class FTerm static bool init_force_vt100_encoding(); static void init_utf8_without_alt_charset(); static void init_tab_quirks(); + static void init_captureFontAndTitle(); static void redefineColorPalette(); static void restoreColorPalette(); static void setInsertCursorStyle(); diff --git a/src/fterm.cpp b/src/fterm.cpp index fc148d07..41eb20d0 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -2394,6 +2394,22 @@ void FTerm::init_tab_quirks() } } +//---------------------------------------------------------------------- +void FTerm::init_captureFontAndTitle() +{ + // Save the used xterm font and window title + + xterm->captureFontAndTitle(); + const FString* font = xterm->getFont(); + const FString* title = xterm->getTitle(); + + if ( font ) + save_xterm_font = new FString(*font); + + if ( title ) + save_xterm_title = new FString(*title); +} + //---------------------------------------------------------------------- void FTerm::redefineColorPalette() { @@ -2697,9 +2713,7 @@ void FTerm::init() } // Save the used xterm font and window title - xterm->captureFontAndTitle(); - save_xterm_font = new FString(*(xterm->getFont())); - save_xterm_title = new FString(*(xterm->getTitle())); + init_captureFontAndTitle(); if ( isKdeTerminal() ) setKDECursor(fc::UnderlineCursor); diff --git a/src/test/fstring-test.cpp b/src/test/fstring-test.cpp index dda71be3..71e358ee 100644 --- a/src/test/fstring-test.cpp +++ b/src/test/fstring-test.cpp @@ -210,18 +210,6 @@ void FStringTest::noArgumentTest() empty.clear(); CPPUNIT_ASSERT ( empty.isNull() ); - - const std::string* str1 = 0; - FString s1(*str1); - CPPUNIT_ASSERT ( s1.isEmpty() ); - CPPUNIT_ASSERT ( s1.isNull() ); - CPPUNIT_ASSERT ( ! s1 ); - - const FString* str2 = 0; - FString s2(*str2); - CPPUNIT_ASSERT ( s2.isEmpty() ); - CPPUNIT_ASSERT ( s2.isNull() ); - CPPUNIT_ASSERT ( ! s2 ); } //----------------------------------------------------------------------