From bd30bd4e85a8af6612861a52e3fc8f0a3b16dfad Mon Sep 17 00:00:00 2001 From: Markus Mueller Date: Wed, 22 Feb 2023 17:59:32 +0100 Subject: [PATCH] fix memory leak more rigorously --- src/osdi/osdiregistry.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 7d925e581..827bbe6a0 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -288,6 +288,7 @@ extern OsdiObjectFile load_object_file(const char *input) { if (!path) { fprintf(stderr, "Error opening osdi lib \"%s\": No such file or directory!\n", input); + txfree(path); return INVALID_OBJECT; } @@ -302,6 +303,7 @@ extern OsdiObjectFile load_object_file(const char *input) { * nghash_insert returns NULL if the key (handle) was not already in the table * and the data (DUMMYDATA) that was previously insered (!= NULL) otherwise*/ if (nghash_insert(known_object_files, handle, DUMMYDATA)) { + txfree(path); return EMPTY_OBJECT; } @@ -313,11 +315,10 @@ extern OsdiObjectFile load_object_file(const char *input) { printf("NGSPICE only supports OSDI v%d.%d but \"%s\" targets v%d.%d!", OSDI_VERSION_MAJOR_CURR, OSDI_VERSION_MINOR_CURR, path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); + txfree(path); return INVALID_OBJECT; } - txfree(path); - GET_CONST(OSDI_NUM_DESCRIPTORS, uint32_t); GET_PTR(OSDI_DESCRIPTORS, OsdiDescriptor); @@ -386,6 +387,7 @@ extern OsdiObjectFile load_object_file(const char *input) { }; } + txfree(path); return (OsdiObjectFile){ .entrys = dst, .num_entries = (int)OSDI_NUM_DESCRIPTORS,