mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-07 22:34:18 +01:00
WINGs: fix check for NULL pointer in WMText selection (Coverity #50067)
As pointed by Coverity, there is a small check for NULL pointer when handling triple-click selection in a WMText, however this check is only partially implemented so the code would crash later anyway. This patch implement an appropriate skip to avoid crash, and includes a log message to help debug if the case happens. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
c86de122f9
commit
42febe3cec
@@ -2150,8 +2150,14 @@ static void autoSelectText(Text * tPtr, int clicks)
|
||||
} else if (clicks == 3) {
|
||||
TextBlock *cur = tb;
|
||||
|
||||
while (tb && !tb->first) {
|
||||
while (!tb->first) {
|
||||
tb = tb->prior;
|
||||
if (tb == NULL) {
|
||||
#ifndef NDEBUG
|
||||
wwarning("corrupted list of text blocks in WMText, while searching for first block");
|
||||
#endif
|
||||
goto error_select_3clicks;
|
||||
}
|
||||
}
|
||||
tPtr->sel.y = tb->sections[0]._y;
|
||||
|
||||
@@ -2161,6 +2167,7 @@ static void autoSelectText(Text * tPtr, int clicks)
|
||||
}
|
||||
tPtr->sel.h = tb->sections[tb->nsections - 1]._y + 5 - tPtr->sel.y;
|
||||
|
||||
error_select_3clicks:
|
||||
tPtr->sel.x = 0;
|
||||
tPtr->sel.w = tPtr->docWidth;
|
||||
tPtr->clicked.x = 0; /* only for now, fix sel. code */
|
||||
|
||||
Reference in New Issue
Block a user