|
|
@ -418,7 +418,8 @@ static bool GunzipFile(const ContentInfo *ci)
|
|
|
|
FILE *ftmp = fopen(GetFullFilename(ci, true).c_str(), "rb");
|
|
|
|
FILE *ftmp = fopen(GetFullFilename(ci, true).c_str(), "rb");
|
|
|
|
if (ftmp == nullptr) return false;
|
|
|
|
if (ftmp == nullptr) return false;
|
|
|
|
/* Duplicate the handle, and close the FILE*, to avoid double-closing the handle later. */
|
|
|
|
/* Duplicate the handle, and close the FILE*, to avoid double-closing the handle later. */
|
|
|
|
gzFile fin = gzdopen(dup(fileno(ftmp)), "rb");
|
|
|
|
int fdup = dup(fileno(ftmp));
|
|
|
|
|
|
|
|
gzFile fin = gzdopen(fdup, "rb");
|
|
|
|
fclose(ftmp);
|
|
|
|
fclose(ftmp);
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fout = fopen(GetFullFilename(ci, false).c_str(), "wb");
|
|
|
|
FILE *fout = fopen(GetFullFilename(ci, false).c_str(), "wb");
|
|
|
@ -457,7 +458,12 @@ static bool GunzipFile(const ContentInfo *ci)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fin != nullptr) gzclose(fin);
|
|
|
|
if (fin != nullptr) {
|
|
|
|
|
|
|
|
gzclose(fin);
|
|
|
|
|
|
|
|
} else if (fdup != -1) {
|
|
|
|
|
|
|
|
/* Failing gzdopen does not close the passed file descriptor. */
|
|
|
|
|
|
|
|
close(fdup);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (fout != nullptr) fclose(fout);
|
|
|
|
if (fout != nullptr) fclose(fout);
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|