From 82f280e23e2b31fb67da8a62c2e29bc446348fbd Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 13 Dec 2021 16:12:30 -0500 Subject: [PATCH] Corrected a failure (in the code for many a decade) to properly clean up memory after running "ext2spice". There are apparently still memory leaks somewhere, difficult to diagnose with valgrind, but this fix removes the most substantial leakage and allows "ext2spice" to be run continuously, at least for a while. --- extflat/EFdef.c | 6 ++++++ extract/ExtTech.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extflat/EFdef.c b/extflat/EFdef.c index 358c6b0d..8744ae49 100644 --- a/extflat/EFdef.c +++ b/extflat/EFdef.c @@ -162,6 +162,12 @@ EFDone() } HashKill(&efDevParamTable); + HashStartSearch(&hs); + while (he = HashNext(&efFreeHashTable, &hs)) + { + /* Keys of this table are entries to be free'd */ + freeMagic(he->h_key.h_ptr); + } HashKill(&efFreeHashTable); /* Final cleanup */ diff --git a/extract/ExtTech.c b/extract/ExtTech.c index 3225bf8d..68bb324b 100644 --- a/extract/ExtTech.c +++ b/extract/ExtTech.c @@ -351,8 +351,16 @@ ExtGetDevInfo(idx, devnameptr, devtypeptr, s_rclassptr, d_rclassptr, } if (found == TRUE) break; } - if (t == DBNumTypes) return FALSE; - if (devptr == NULL) return FALSE; + if (t == DBNumTypes) + { + freeMagic(uniquenamelist); + return FALSE; + } + if (devptr == NULL) + { + freeMagic(uniquenamelist); + return FALSE; + } if (devnameptr) *devnameptr = locdname; if (subnameptr) *subnameptr = devptr->exts_deviceSubstrateName;