Commit Diff


commit - 01392bd60410ca454e46653c8a740008e84545ef
commit + 161b566ff8fdc61984f077c6ab1d75b5f0fd5ac7
blob - 8fa42a873d1dd3feb591275a17e1bd546c3dab59
blob + c8d4003646dbbf24c3e252839931cf8e83181583
--- lib/object_create.c
+++ lib/object_create.c
@@ -198,9 +198,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);
@@ -392,9 +392,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);
@@ -581,9 +581,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);
@@ -848,9 +848,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);