fix memory leak more rigorously

This commit is contained in:
Markus Mueller 2023-02-22 17:59:32 +01:00
parent 15e9d749e2
commit 97f31d5a20
1 changed files with 4 additions and 2 deletions

View File

@ -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,