Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 585a50ce authored by Tao Bao's avatar Tao Bao Committed by Gerrit Code Review
Browse files

Merge "imgdiff: fix file descriptor leak"

parents f8c303f9 a91c66d7
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -628,7 +628,15 @@ unsigned char* MakePatch(ImageChunk* src, ImageChunk* tgt, size_t* size) {
  }

  char ptemp[] = "/tmp/imgdiff-patch-XXXXXX";
  mkstemp(ptemp);
  int fd = mkstemp(ptemp);

  if (fd == -1) {
    printf("MakePatch failed to create a temporary file: %s\n",
           strerror(errno));
    return NULL;
  }
  close(fd); // temporary file is created and we don't need its file
             // descriptor

  int r = bsdiff(src->data, src->len, &(src->I), tgt->data, tgt->len, ptemp);
  if (r != 0) {