rdp_plugin.c: Fix dereferencing of NULL variable when profile name is empty
Description
The conditional was backwards so the while
loop tried to dereference p
when it was NULL
instead of when it was not NULL
.
This also fixes the thread name being empty instead of RemmRDP:<NONAM>
when no name is specified.
Related Issue
Fixes: #2559 (closed)
Motivation and Context
Fixes segfault
How Has This Been Tested?
Confirmed that the thread name is correctly set when the profile name is empty:
(gdb) info locals
rfi = 0x555555c30070
remminafile = 0x555555817610
profile_name = <optimized out>
p = 0x0
thname = "RemmRDP:<NONAM>"
c = <optimized out>
nthname = 15
(gdb)
❯ ps -eTl | grep RemmRDP
1 t 1000 280278 280289 280271 0 80 0 - 141575 - pts/7 00:00:00 RemmRDP:<NONAM>
and when the profile name is set to Test
:
(gdb) info locals
rfi = 0x5555563b4400
remminafile = 0x5555565a8190
profile_name = <optimized out>
p = 0x55555650cab4 ""
thname = "RemmRDP:Test\000\177\000"
c = <optimized out>
nthname = 12
❯ ps -eTl | grep RemmRDP
1 t 1000 280278 280592 280271 0 80 0 - 286284 - pts/7 00:00:00 RemmRDP:Test
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
-
My code follows the code style of this project. -
My change requires a change to the documentation. -
I have updated the documentation accordingly.