]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
upkg: Don't forget to close the opened export.
[upkg.git] / src / upkg.c
index ed6d4dfdeaf8a9844d51e4f22d3a6eda1912699d..82a673d100ccc6c522bd597713608ab40d3cd7fb 100644 (file)
@@ -156,10 +156,10 @@ static int export(struct upkg *pkg, GObject *obj, unsigned idx)
        struct upkg_file *f = upkg_export_open(pkg, idx);
        char name[256];
        FILE *of;
-       int rc;
+       int rc = -1;
 
        if (u_object_deserialize(obj, f) != 0) {
-               return -1;
+               goto out;
        }
        u_object_export_name(obj, name, sizeof name);
 
@@ -167,16 +167,19 @@ static int export(struct upkg *pkg, GObject *obj, unsigned idx)
        of = fopen(name, "wb");
        if (!of) {
                perror(name);
-               return -1;
+               goto out;
        }
 
        rc = u_object_export(obj, of);
 
        if (fclose(of) != 0) {
                perror(name);
-               return -1;
+               rc = -1;
+               goto out;
        }
 
+out:
+       upkg_export_close(f);
        return rc;
 }