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 0e08342..0b5be94 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;

Attachment: 0001-WINGs-correct-possible-null-pointer-dereference.patch
Description: Binary data

Reply via email to