@matheusbsbs / matheus-bagliano / commits / 59dd9ed183
Fork 0

pack-objects: don't leak pack window reference when splitting packs

Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Oct 29, 2008 at 19:02 UTC 59dd9ed18398d96922e345f7987f1245870fb3e5
1 file changed +9 -3
builtin-pack-objects.c
+9 -3
@@ -389,22 +389,28 @@ static unsigned long write_object(struct sha1file *f,
389 dheader[pos] = ofs & 127;
390 while (ofs >>= 7)
391 dheader[--pos] = 128 | (--ofs & 127);
392 - if (limit && hdrlen + sizeof(dheader) - pos + datalen + 20 >= limit)
392 + if (limit && hdrlen + sizeof(dheader) - pos + datalen + 20 >= limit) {
393 + unuse_pack(&w_curs);
394 return 0;
395 + }
396 sha1write(f, header, hdrlen);
397 sha1write(f, dheader + pos, sizeof(dheader) - pos);
398 hdrlen += sizeof(dheader) - pos;
399 reused_delta++;
400 } else if (type == OBJ_REF_DELTA) {
399 - if (limit && hdrlen + 20 + datalen + 20 >= limit)
401 + if (limit && hdrlen + 20 + datalen + 20 >= limit) {
402 + unuse_pack(&w_curs);
403 return 0;
404 + }
405 sha1write(f, header, hdrlen);
406 sha1write(f, entry->delta->idx.sha1, 20);
407 hdrlen += 20;
408 reused_delta++;
409 } else {
406 - if (limit && hdrlen + datalen + 20 >= limit)
410 + if (limit && hdrlen + datalen + 20 >= limit) {
411 + unuse_pack(&w_curs);
412 return 0;
413 + }
414 sha1write(f, header, hdrlen);
415 }
416 copy_pack_data(f, p, &w_curs, offset, datalen);