Commit d0f3be7ced58c524baf1ac738b44c04317bcb757

Stefan Sperling 2018-03-17T15:17:14

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;
 }