From ed6ed03c0f47f794ba7de68b23f1074cc94d8f60 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Mon, 15 Dec 2025 10:31:48 +0000 Subject: [PATCH] fix: regression: avoid null pointer dereference in CleanDollarFactors This function can be called with nfactors = 1, but with no array allocated on d->factors. --- sources/dollar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sources/dollar.c b/sources/dollar.c index 3c292a49..cdfc1faf 100644 --- a/sources/dollar.c +++ b/sources/dollar.c @@ -3556,8 +3556,9 @@ void CleanDollarFactors(DOLLARS d) int i; if ( d->nfactors >= 1 ) { for ( i = 0; i < d->nfactors; i++ ) { - if ( d->factors[i].where ) - M_free(d->factors[i].where,"dollar factors"); + if ( d->factors ) + if ( d->factors[i].where ) + M_free(d->factors[i].where,"dollar factors"); } } if ( d->factors ) {