From: Michael Tremer Date: Tue, 5 Oct 2021 11:59:20 +0000 (+0000) Subject: pakfire_free: Avoid multiple calls X-Git-Tag: 0.9.28~912 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8d72bf89c4f3bb367ac240bb7d0c6ae2a47971d;p=pakfire.git pakfire_free: Avoid multiple calls If we want to access any objects that use reference counting, we will increment and then decrement the reference counter of struct pakfire. This will cause that pakfire_free() will be called multiple times which will go wrong. This change blocks that that will happen. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 8bde301e1..56606ed4d 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -110,6 +110,7 @@ struct pakfire { int destroy_on_free:1; int mount_tmpfs:1; int pool_ready:1; + int in_free:1; }; /* @@ -513,6 +514,10 @@ static int pakfire_mount_interpreter(struct pakfire* pakfire) { } static void pakfire_free(struct pakfire* pakfire) { + // Avoid recursive free + if (pakfire->in_free++) + return; + // Release GPGME context if (pakfire->gpgctx) pakfire_keystore_destroy(pakfire, &pakfire->gpgctx);