From 39e13982579c9be433a7a7185c2e69e30f91d5db Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Sun, 27 Jul 2014 14:15:51 +0800 Subject: [PATCH] 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. --- WINGs/array.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WINGs/array.c b/WINGs/array.c index 0e083428..0b5be944 100644 --- a/WINGs/array.c +++ b/WINGs/array.c @@ -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;