commit 0ee7a4dc0068ae010131e514f6464c5134f0353e from: Stefan Sperling date: Wed Jan 26 10:33:21 2022 UTC fix double-free and double-close issues in error paths of got_packidx_open() commit - 692bdcc498e440f1604cf7ba8a5cac22966c2ece commit + 0ee7a4dc0068ae010131e514f6464c5134f0353e blob - d023ca662cadef23be987f2cb6408ceb599a0ebc blob + 8a01d22a8f4fe6686821dab1e44a139ea351a8a1 --- lib/pack.c +++ lib/pack.c @@ -371,21 +371,16 @@ got_packidx_open(struct got_packidx **packidx, p->fd = openat(dir_fd, relpath, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); if (p->fd == -1) { err = got_error_from_errno2("openat", relpath); - free(p); goto done; } if (fstat(p->fd, &idx_sb) != 0) { err = got_error_from_errno2("fstat", relpath); - close(p->fd); - free(p); goto done; } p->len = idx_sb.st_size; if (p->len < sizeof(p->hdr)) { err = got_error(GOT_ERR_BAD_PACKIDX); - close(p->fd); - free(p); goto done; }