From 3b9ca877a45c57200dadf71f4802e3a0748516e3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 14:43:04 +0200 Subject: [PATCH] mi: NULL-protect miFillGeneralPoly() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | In file included from ../mi/mipoly.c:59: | ../mi/mipoly.c: In function ‘miFillGeneralPoly’: | ../mi/mipoly.h:162:12: warning: dereference of NULL ‘pAET’ [CWE-476] [-Wanalyzer-null-dereference] | 162 | if (pAET->ymax == y) { /* leaving this edge */ \ | ../mi/mipoly.c:591:17: note: in expansion of macro ‘EVALUATEEDGEEVENODD’ | 591 | EVALUATEEDGEEVENODD(pAET, pPrevAET, y); | | ^~~~~~~~~~~~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult --- mi/mipoly.c | 6 ++++-- mi/mipoly.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mi/mipoly.c b/mi/mipoly.c index 3cdb56925..4b068e7e2 100644 --- a/mi/mipoly.c +++ b/mi/mipoly.c @@ -587,8 +587,10 @@ miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn) width = FirstWidth; nPts = 0; } - EVALUATEEDGEEVENODD(pAET, pPrevAET, y); - EVALUATEEDGEEVENODD(pAET, pPrevAET, y); + if (pAET != NULL) { // FIXME: somewhow analyzer still complains + EVALUATEEDGEEVENODD(pAET, pPrevAET, y); + EVALUATEEDGEEVENODD(pAET, pPrevAET, y); + } } miInsertionSort(&AET); } diff --git a/mi/mipoly.h b/mi/mipoly.h index d67a5249e..10632f232 100644 --- a/mi/mipoly.h +++ b/mi/mipoly.h @@ -159,6 +159,7 @@ typedef struct _ScanLineListBlock { * The even-odd rule is in effect. */ #define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ + assert(pAET); \ if (pAET->ymax == y) { /* leaving this edge */ \ pPrevAET->next = pAET->next; \ pAET = pPrevAET->next; \