windows/windDisp.c: Redundant null check due to previous dereference

Fix code scanning alert no. 133: Redundant null check due to previous dereference (#40)

* Update windDisp.c

* DLM - AI wanted to guard the '*area' dereference in if() statement, but the code path above has address of '&' operator for the assignment to 'area' so it must always be non-null.  So I rejected this approach and removed the extra null check, replacing it with an assert().

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Darryl Miles 2024-09-30 06:21:20 +01:00 committed by Tim Edwards
parent 499ac84ac0
commit d1dc038cb7
1 changed files with 5 additions and 2 deletions

View File

@ -19,6 +19,7 @@
static char rcsid[] __attribute__ ((unused)) = "$Header$";
#endif /* not lint */
#include <assert.h>
#include <stdio.h>
#include "tcltk/tclmagic.h"
@ -337,9 +338,11 @@ WindAreaChanged(w, area)
/* will be copied into on the next display redraw. */
if ((w != NULL) && (w->w_backingStore == (ClientData)NULL) &&
(!(w->w_flags & WIND_OBSCURED)) && (GrCreateBackingStorePtr != NULL))
if ((area == (Rect *)NULL) || GEO_SURROUND(&biggerArea, &w->w_screenArea))
(!(w->w_flags & WIND_OBSCURED)) && (GrCreateBackingStorePtr != NULL)) {
assert(area); // area is non-null
if (GEO_SURROUND(&biggerArea, &w->w_screenArea))
(*GrCreateBackingStorePtr)(w);
}
}
int