receive-pack: close sideband fd on early pack errors
[gitweb.git] / builtin / receive-pack.c
index ff781febcad92dfccd8a3d97d0414526ded36943..ce42c0a5263e54596003d2c9f4d39e0435326f78 100644 (file)
@@ -807,8 +807,11 @@ static const char *unpack(int err_fd)
                            : 0);
 
        hdr_err = parse_pack_header(&hdr);
-       if (hdr_err)
+       if (hdr_err) {
+               if (err_fd > 0)
+                       close(err_fd);
                return hdr_err;
+       }
        snprintf(hdr_arg, sizeof(hdr_arg),
                        "--pack_header=%"PRIu32",%"PRIu32,
                        ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));