From 35175882bcfe4cc2afe4ddd992a2aa87aeebfca2 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 8 May 2020 17:02:36 -0400 Subject: [PATCH] Corrected another similar bit of code causing a segfault. It is not known, though, why the flag is set indicating valid planes in the clientdata record when there in fact is none. That seems to be the underlying bug. --- cif/CIFrdcl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cif/CIFrdcl.c b/cif/CIFrdcl.c index 7edc8845..553c79cc 100644 --- a/cif/CIFrdcl.c +++ b/cif/CIFrdcl.c @@ -1497,15 +1497,20 @@ CIFReadCellCleanup(filetype) UndoDisable(); - for (pNum = 0; pNum < MAXCIFRLAYERS; pNum++) + /* cifplanes should be valid, but don't crash magic if not */ + if (cifplanes != (ClientData)CLIENTDEFAULT) { - if (cifplanes[pNum] != NULL) + + for (pNum = 0; pNum < MAXCIFRLAYERS; pNum++) { - DBFreePaintPlane(cifplanes[pNum]); - TiFreePlane(cifplanes[pNum]); + if (cifplanes[pNum] != NULL) + { + DBFreePaintPlane(cifplanes[pNum]); + TiFreePlane(cifplanes[pNum]); + } } + freeMagic((char *)def->cd_client); } - freeMagic((char *)def->cd_client); def->cd_client = (ClientData)CLIENTDEFAULT; #if 0