Commit Diff


commit - 8f464e92b2e71ae647c139f4937a2390d159eec2
commit + 25b84e6cea4c9658ea8ffc7af2928f0b254069ca
blob - 6edf50f52da0daa282b26ccb4fa82b57283d55bc
blob + c253f2858befebc7bcbb97937e35ee98403a4738
--- lib/object_create.c
+++ lib/object_create.c
@@ -199,9 +199,9 @@ got_object_blob_file_create(struct got_object_id **id,
 			break;
 	}
 
-	*id = malloc(sizeof(**id));
+	*id = calloc(1, sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_from_errno("malloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
@@ -393,9 +393,9 @@ got_object_tree_create(struct got_object_id **id,
 		treesize += n;
 	}
 
-	*id = malloc(sizeof(**id));
+	*id = calloc(1, sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_from_errno("malloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
@@ -582,9 +582,9 @@ got_object_commit_create(struct got_object_id **id,
 	}
 	commitsize += n;
 
-	*id = malloc(sizeof(**id));
+	*id = calloc(1, sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_from_errno("malloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
@@ -849,9 +849,9 @@ got_object_tag_create(struct got_object_id **id,
 		tagsize += n;
 	}
 
-	*id = malloc(sizeof(**id));
+	*id = calloc(1, sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_from_errno("malloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);