]> git.ipfire.org Git - pakfire.git/commitdiff
cli: Fail if the context wasn't freed in the end
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jan 2025 18:01:44 +0000 (18:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jan 2025 18:01:44 +0000 (18:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/pakfire-builder.c
src/cli/pakfire-client.c
src/cli/pakfire-daemon.c
src/cli/pakfire.c

index d0aa30303e81685e2a7941cd091fdba0ed74473e..1e0890dc5d68079ef9b2e50ccc2bce7830d42e10 100644 (file)
@@ -185,8 +185,13 @@ int main(int argc, char* argv[]) {
                parse, CLI_REQUIRE_ROOT, argc, argv, &args);
 
 ERROR:
-       if (ctx)
-               pakfire_ctx_unref(ctx);
+       if (ctx) {
+               ctx = pakfire_ctx_unref(ctx);
+               if (ctx) {
+                       fprintf(stderr, "Context was not freed\n");
+                       return 1;
+               }
+       }
 
        return r;
 }
index 3b99a0676ba69adce020789371cec9a86d49d5bd..14828a1088f3da92d69dd1ea0eb2165407006a0d 100644 (file)
@@ -98,8 +98,13 @@ int main(int argc, char* argv[]) {
                parse, 0, argc, argv, &args);
 
 ERROR:
-       if (ctx)
-               pakfire_ctx_unref(ctx);
+       if (ctx) {
+               ctx = pakfire_ctx_unref(ctx);
+               if (ctx) {
+                       fprintf(stderr, "Context was not freed\n");
+                       return 1;
+               }
+       }
 
        return r;
 }
index e0d1f094dcf77043f8854d8308f8a8a73d68a148..a02a372c6ed1ffe6922c62674a5d2dfaa3386847 100644 (file)
@@ -74,8 +74,13 @@ int main(int argc, char* argv[]) {
        r = cli_daemon_main(ctx);
 
 ERROR:
-       if (ctx)
-               pakfire_ctx_unref(ctx);
+       if (ctx) {
+               ctx = pakfire_ctx_unref(ctx);
+               if (ctx) {
+                       fprintf(stderr, "Context was not freed\n");
+                       return 1;
+               }
+       }
 
        return r;
 }
index d83737ea5779f9af48933a9315b5374ebdfb8b33..bde3e06a6aad0ee88e7e6e5341e1f6c3e3f55d5e 100644 (file)
@@ -169,8 +169,13 @@ int main(int argc, char* argv[]) {
                CLI_REQUIRE_ROOT, argc, argv, &args);
 
 ERROR:
-       if (ctx)
-               pakfire_ctx_unref(ctx);
+       if (ctx) {
+               ctx = pakfire_ctx_unref(ctx);
+               if (ctx) {
+                       fprintf(stderr, "Context was not freed\n");
+                       return 1;
+               }
+       }
 
        return r;
 }