initialize some output variables on failure
diff --git a/lib/object.c b/lib/object.c
index 1a04ad4..e3b651d 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -756,6 +756,7 @@ got_object_blob_open(struct got_blob_object **blob,
err = open_loose_object(&((*blob)->f), obj, repo);
if (err) {
free(*blob);
+ *blob = NULL;
return err;
}
diff --git a/lib/pack.c b/lib/pack.c
index f56f614..de4af7d 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -1381,8 +1381,10 @@ got_packfile_extract_object(FILE **f, struct got_object *obj,
pack, repo);
}
done:
- if (err && *f)
+ if (err && *f) {
fclose(*f);
+ *f = NULL;
+ }
return err;
}