Commit c743ac7dd29b36dd1baf4857bcfa512b34b28da7

Stefan Sperling 2018-01-27T03:27:41

remove pointless loops in read_{commit,tree}_object()

diff --git a/lib/object.c b/lib/object.c
index 8bec1d8..58a2acc 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -510,11 +510,9 @@ read_commit_object(struct got_commit_object **commit,
 	if (err)
 		return err;
 
-	do {
-		err = got_inflate_read(&zb, f, NULL, &len);
-		if (err || len == 0)
-			break;
-	} while (len < obj->hdrlen + obj->size);
+	err = got_inflate_read(&zb, f, NULL, &len);
+	if (err)
+		return err;
 
 	if (len < obj->hdrlen + obj->size) {
 		err = got_error(GOT_ERR_BAD_OBJ_DATA);
@@ -579,11 +577,9 @@ read_tree_object(struct got_tree_object **tree,
 	if (err)
 		return err;
 
-	do {
-		err = got_inflate_read(&zb, f, NULL, &len);
-		if (err || len == 0)
-			break;
-	} while (len < obj->hdrlen + obj->size);
+	err = got_inflate_read(&zb, f, NULL, &len);
+	if (err)
+		return err;
 
 	if (len < obj->hdrlen + obj->size) {
 		err = got_error(GOT_ERR_BAD_OBJ_DATA);