From f971c36abea40fdee00627bb1af83b59bdd5033e Mon Sep 17 00:00:00 2001 From: tsujan Date: Thu, 16 May 2024 19:37:27 +0330 Subject: [PATCH] Fixed comparison of pointer addition with NULL (#549) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comparison was added to fix a crash under Plasma-Wayland, when the terminal was split horizontally. Instead, a simple nullity check was enough. The following compilation warning is also silenced: ``` qtermwidget/lib/TerminalCharacterDecoder.cpp:85:28: warning: comparing the result of pointer addition ‘(((const Konsole::Character*)characters) + ((sizetype)(((long unsigned int)i) * 16)))’ and NULL [-Waddress] 85 | if (characters + i == nullptr) ``` --- lib/TerminalCharacterDecoder.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/TerminalCharacterDecoder.cpp b/lib/TerminalCharacterDecoder.cpp index b42010bd..5cdd65ab 100644 --- a/lib/TerminalCharacterDecoder.cpp +++ b/lib/TerminalCharacterDecoder.cpp @@ -79,14 +79,11 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count, _linePositions << pos; } - // check the real length - for (int i = 0 ; i < count ; i++) + if (characters == nullptr) { - if (characters + i == nullptr) - { - count = i; - break; - } + // TODO: So far, this has happened only under kwin_wayland, when the current function + // is called by TerminalDisplay::inputMethodQuery(). The actual issue should be found. + return; } //TODO should we ignore or respect the LINE_WRAPPED line property?