1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

WINGs: correct possible null pointer dereference

As reported by cppcheck:

[WINGs/array.c:129] -> [WINGs/array.c:131]: (warning) Possible null pointer dereference: array - otherwise it is redundant to check it against null.
[WINGs/array.c:151] -> [WINGs/array.c:153]: (warning) Possible null pointer dereference: array - otherwise it is redundant to check it against null.
[WINGs/array.c:170] -> [WINGs/array.c:172]: (warning) Possible null pointer dereference: array - otherwise it is redundant to check it against null.

This patch is checking that the var name 'array' exists.
This commit is contained in:
David Maciejak
2014-07-27 14:15:51 +08:00
committed by Carlos R. Mafra
parent abc2d13f7d
commit 39e1398257

View File

@@ -126,7 +126,7 @@ void WMAddToArray(WMArray * array, void *item)
void WMInsertInArray(WMArray * array, int index, void *item)
{
wassertr(index >= 0 && index <= array->itemCount);
wassertr(array && index >= 0 && index <= array->itemCount);
if (array == NULL)
return;
@@ -148,7 +148,7 @@ void *WMReplaceInArray(WMArray * array, int index, void *item)
{
void *old;
wassertrv(index >= 0 && index <= array->itemCount, NULL);
wassertrv(array && index >= 0 && index <= array->itemCount, NULL);
if (array == NULL)
return NULL;
@@ -167,7 +167,7 @@ void *WMReplaceInArray(WMArray * array, int index, void *item)
int WMDeleteFromArray(WMArray * array, int index)
{
wassertrv(index >= 0 && index < array->itemCount, 0);
wassertrv(array && index >= 0 && index < array->itemCount, 0);
if (array == NULL)
return 0;