From d1dc038cb77f34ccad13653148bce761bbb98780 Mon Sep 17 00:00:00 2001 From: Darryl Miles Date: Mon, 30 Sep 2024 06:21:20 +0100 Subject: [PATCH] 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> --- windows/windDisp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/windows/windDisp.c b/windows/windDisp.c index 63f8f40a..91b3533d 100644 --- a/windows/windDisp.c +++ b/windows/windDisp.c @@ -19,6 +19,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header$"; #endif /* not lint */ +#include #include #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