From 89dceb5e9a549f86eb4cefca810fde96cd645d7d Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Wed, 6 Nov 2024 22:48:32 +0100 Subject: [PATCH] Fix double free in test_collection --- src/dlite-collection.c | 4 ++-- src/tests/test_collection.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dlite-collection.c b/src/dlite-collection.c index 3b66c0b19..1db3edeb6 100644 --- a/src/dlite-collection.c +++ b/src/dlite-collection.c @@ -45,8 +45,8 @@ int dlite_collection_deinit(DLiteInstance *inst) while ((r=dlite_collection_find(coll,&state, NULL, "_has-uuid", NULL, NULL))) { if ((inst2 = dlite_instance_get(r->o))) { - dlite_instance_decref(inst2); - dlite_instance_decref(inst2); + dlite_instance_decref(inst2); // remove ref from collection + dlite_instance_decref(inst2); // remove local ref to inst2 } else { warnx("cannot remove missing instance: %s", r->o); } diff --git a/src/tests/test_collection.c b/src/tests/test_collection.c index 8f713627d..19690f74a 100644 --- a/src/tests/test_collection.c +++ b/src/tests/test_collection.c @@ -263,7 +263,6 @@ MU_TEST(test_collection_load) //dlite_json_print((DLiteInstance *)inst); //printf("----------------------\n"); - dlite_instance_decref((DLiteInstance *)inst); dlite_collection_decref(coll2); }