commit 67af9f37413a2529ee144aa57def023a428dd996 from: Stefan Sperling via: Thomas Adam date: Sat Feb 12 17:21:49 2022 UTC fix double-free and double-close issues in error paths of got_packidx_open() commit - a75b210eed1d491d23b0cfef8ac3a51607bf2c19 commit + 67af9f37413a2529ee144aa57def023a428dd996 blob - 69a1daf4a2c1047bb38b4801085ed055ac118786 blob + af8b3b6ea7ef7080ce1af924448188a64e05b5aa --- lib/pack.c +++ lib/pack.c @@ -367,21 +367,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; }