Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'jk/index-pack-streaming-fix' into pu

* jk/index-pack-streaming-fix:
  index-pack: loop while inflating objects in unpack_data
  • Loading branch information...
commit 5e3341b88a01bd1bc2c56cc5960cf4b117976e1a 2 parents 1f4cccf + f8b0903
Junio C Hamano authored July 10, 2012

Showing 1 changed file with 13 additions and 10 deletions. Show diff stats Hide diff stats

  1. 23  builtin/index-pack.c
23  builtin/index-pack.c
@@ -524,7 +524,6 @@ static void *unpack_data(struct object_entry *obj,
524 524
 	stream.avail_out = consume ? 64*1024 : obj->size;
525 525
 
526 526
 	do {
527  
-		unsigned char *last_out = stream.next_out;
528 527
 		ssize_t n = (len < 64*1024) ? len : 64*1024;
529 528
 		n = pread(pack_fd, inbuf, n, from);
530 529
 		if (n < 0)
@@ -538,15 +537,19 @@ static void *unpack_data(struct object_entry *obj,
538 537
 		len -= n;
539 538
 		stream.next_in = inbuf;
540 539
 		stream.avail_in = n;
541  
-		status = git_inflate(&stream, 0);
542  
-		if (consume) {
543  
-			if (consume(last_out, stream.next_out - last_out, cb_data)) {
544  
-				free(inbuf);
545  
-				free(data);
546  
-				return NULL;
547  
-			}
548  
-			stream.next_out = data;
549  
-			stream.avail_out = 64*1024;
  540
+		if (!consume)
  541
+			status = git_inflate(&stream, 0);
  542
+		else {
  543
+			do {
  544
+				status = git_inflate(&stream, 0);
  545
+				if (consume(data, stream.next_out - data, cb_data)) {
  546
+					free(inbuf);
  547
+					free(data);
  548
+					return NULL;
  549
+				}
  550
+				stream.next_out = data;
  551
+				stream.avail_out = 64*1024;
  552
+			} while (status == Z_OK && stream.avail_in);
550 553
 		}
551 554
 	} while (len && status == Z_OK && !stream.avail_in);
552 555
 

0 notes on commit 5e3341b

Please sign in to comment.
Something went wrong with that request. Please try again.