pack-objects: return early when computing write order fails The function `compute_write_order` may return a `NULL`-pointer when an error occurs. In such cases we jump to the `done`-label where we try to clean up allocated memory. Unfortunately we try to deallocate the `write_order` array, though, which may be NULL here. Fix this error by returning early instead of jumping to the `done` label. There is no data to be cleaned up anyway.
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 5d9c09d..46fe8f3 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -629,10 +629,8 @@ static int write_pack(git_packbuilder *pb,
int error = 0;
write_order = compute_write_order(pb);
- if (write_order == NULL) {
- error = -1;
- goto done;
- }
+ if (write_order == NULL)
+ return -1;
/* Write pack header */
ph.hdr_signature = htonl(PACK_SIGNATURE);