Skip to content

Commit

Permalink
Fixed comparison of pointer addition with NULL
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
tsujan committed May 9, 2024
1 parent 075ec89 commit d93a3ce
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/TerminalCharacterDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit d93a3ce

Please sign in to comment.