From 97913ab08c521a2350bfd55026b24a9d41a7b5bc Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 20:08:52 +0100 Subject: [PATCH] calma/CalmaWrite.c: calmaProcessBoundaryZ() Dereference of null pointer Theoretical NULL pointer deref. Seems like false positive as a BOUNDARY record does not make sense with no points. This guards against a potential crash from a bad data model. SonarCloud Dereference of null pointer https://sonarcloud.io/project/issues?open=AZJB17hwNGfDNup0Rkub&id=dlmiles_magic --- calma/CalmaWriteZ.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/calma/CalmaWriteZ.c b/calma/CalmaWriteZ.c index 557541b4..b60f0b6d 100644 --- a/calma/CalmaWriteZ.c +++ b/calma/CalmaWriteZ.c @@ -1830,8 +1830,11 @@ calmaProcessBoundaryZ( calmaOutI4Z(lbref->lb_start.p_y * calmaPaintScale, f); chkcount++; } - calmaOutI4Z(listtop->lb_start.p_x * calmaPaintScale, f); - calmaOutI4Z(listtop->lb_start.p_y * calmaPaintScale, f); + if (listtop != NULL) + { + calmaOutI4Z(listtop->lb_start.p_x * calmaPaintScale, f); + calmaOutI4Z(listtop->lb_start.p_y * calmaPaintScale, f); + } if (chkcount != bounds->bt_points) TxError("Points recorded=%d; Points written=%d\n",