]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Don't duplicate and leak arch
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Oct 2024 12:08:26 +0000 (12:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Oct 2024 11:31:58 +0000 (11:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 54852dc84838ad7ed6edb1ef4f2e51dbb5b3aafc..2f158942925b8969bce123c1fa7a67fa06ea7c42 100644 (file)
@@ -1030,19 +1030,15 @@ int pakfire_parser_create_package(struct pakfire_parser* parser,
        // Fetch arch
        arch = pakfire_parser_get(parser, namespace, "arch");
        if (!arch || !*arch) {
-               if (default_arch) {
-                       arch = strdup(default_arch);
-                       if (!arch)
-                               goto CLEANUP;
-               } else {
+               if (!default_arch) {
                        ERROR(parser->ctx, "Arch is empty\n");
                        goto CLEANUP;
                }
        }
 
        // Create a new package object
-       r = pakfire_package_create(pkg, parser->pakfire, repo, name, evr, arch);
-       if (r) {
+       r = pakfire_package_create(pkg, parser->pakfire, repo, name, evr, (arch) ? arch : default_arch);
+       if (r < 0) {
                ERROR(parser->ctx, "Could not create package: %m\n");
                goto CLEANUP;
        }