mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 20:10:29 +01:00
As pointed by Coverity, it is possible to dereference the NULL pointer in
the function 'browseForFile'.
This should have been reported by the compiler ("possible use of
uninitialised variable") but the assignation of a default value to the
variable 'lPtr' hides this, but as the default value is not a good one then
the code could crash.
This patch removes the default value, so we may have some info from the
compiler and handles the case smoothly.
It also fixes a potential memory leak pointed also by Coverity in the
case where the string returned by WMGetFilePanelFileName would be a 0
length non-null string.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
c5744aaa8b
commit
4b7bb5bc5c
@@ -149,22 +149,24 @@ static void browseForFile(WMWidget * w, void *data)
|
||||
len--;
|
||||
}
|
||||
if (len > 0) {
|
||||
WMList *lPtr = NULL;
|
||||
WMList *lPtr;
|
||||
int i;
|
||||
|
||||
if (w == panel->icoaB)
|
||||
lPtr = panel->icoL;
|
||||
else if (w == panel->pixaB)
|
||||
lPtr = panel->pixL;
|
||||
else
|
||||
goto error_unknown_widget;
|
||||
|
||||
i = WMGetListSelectedItemRow(lPtr);
|
||||
if (i >= 0)
|
||||
i++;
|
||||
addPathToList(lPtr, i, str);
|
||||
WMSetListBottomPosition(lPtr, WMGetListNumberOfRows(lPtr));
|
||||
|
||||
wfree(str);
|
||||
}
|
||||
error_unknown_widget:
|
||||
wfree(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user