mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +01:00
As pointed by Coverity, there were some null pointer checks that had been misplaced, due to a pointer dereference present in a preceding check. This had been fixed by adding another null check in the check, making a duplicate check. This patch moves the null pointer check in first place, and remove the pointer check from the range check to separate the pointer check on one side and the range check on the other side. Signed-off-by: Christophe CURIS <christophe.curis@free.fr> Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
40139e208b
commit
662b83769a
@@ -126,11 +126,11 @@ void WMAddToArray(WMArray * array, void *item)
|
||||
|
||||
void WMInsertInArray(WMArray * array, int index, void *item)
|
||||
{
|
||||
wassertr(array && index >= 0 && index <= array->itemCount);
|
||||
|
||||
if (array == NULL)
|
||||
return;
|
||||
|
||||
wassertr(index >= 0 && index <= array->itemCount);
|
||||
|
||||
if (array->itemCount >= array->allocSize) {
|
||||
array->allocSize += RESIZE_INCREMENT;
|
||||
array->items = wrealloc(array->items, sizeof(void *) * array->allocSize);
|
||||
@@ -148,11 +148,11 @@ void *WMReplaceInArray(WMArray * array, int index, void *item)
|
||||
{
|
||||
void *old;
|
||||
|
||||
wassertrv(array && index >= 0 && index <= array->itemCount, NULL);
|
||||
|
||||
if (array == NULL)
|
||||
return NULL;
|
||||
|
||||
wassertrv(index >= 0 && index <= array->itemCount, NULL);
|
||||
|
||||
/* is it really useful to perform append if index == array->itemCount ? -Dan */
|
||||
if (index == array->itemCount) {
|
||||
WMAddToArray(array, item);
|
||||
@@ -167,11 +167,11 @@ void *WMReplaceInArray(WMArray * array, int index, void *item)
|
||||
|
||||
int WMDeleteFromArray(WMArray * array, int index)
|
||||
{
|
||||
wassertrv(array && index >= 0 && index < array->itemCount, 0);
|
||||
|
||||
if (array == NULL)
|
||||
return 0;
|
||||
|
||||
wassertrv(index >= 0 && index < array->itemCount, 0);
|
||||
|
||||
if (array->destructor) {
|
||||
array->destructor(array->items[index]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user