| Index: third_party/zlib/google/zip_internal.cc
|
| diff --git a/third_party/zlib/google/zip_internal.cc b/third_party/zlib/google/zip_internal.cc
|
| index d62e0bbf21141b32194612d567e962f052463d2c..183303c358eca69a867cc9ca94b122d279230363 100644
|
| --- a/third_party/zlib/google/zip_internal.cc
|
| +++ b/third_party/zlib/google/zip_internal.cc
|
| @@ -90,17 +90,17 @@ void* FdOpenFileFunc(void* opaque, const char* filename, int mode) {
|
| else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
| mode_fopen = "wb";
|
|
|
| - if ((filename != NULL) && (mode_fopen != NULL))
|
| - file = fdopen(*static_cast<int*>(opaque), mode_fopen);
|
| + if ((filename != NULL) && (mode_fopen != NULL)) {
|
| + int fd = dup(*static_cast<int*>(opaque));
|
| + if (fd != -1)
|
| + file = fdopen(fd, mode_fopen);
|
| + }
|
|
|
| return file;
|
| }
|
|
|
| -// We don't actually close the file stream since that would close
|
| -// the underlying file descriptor, and we don't own it. However we do need to
|
| -// flush buffers and free |opaque| since we malloc'ed it in FillFdOpenFileFunc.
|
| int CloseFileFunc(void* opaque, void* stream) {
|
| - fflush(static_cast<FILE*>(stream));
|
| + fclose(static_cast<FILE*>(stream));
|
| free(opaque);
|
| return 0;
|
| }
|
| @@ -131,6 +131,11 @@ void* HandleOpenFileFunc(void* opaque, const char* filename, int mode) {
|
| *(static_cast<WIN32FILE_IOWIN*>(ret)) = file_ret;
|
| return ret;
|
| }
|
| +
|
| +int HandleCloseFileFunc(void* opaque, void* stream) {
|
| + free(stream); // malloc'ed in HandleOpenFileFunc()
|
| + return 0;
|
| +}
|
| #endif
|
|
|
| // A struct that contains data required for zlib functions to extract files from
|
| @@ -282,6 +287,7 @@ unzFile OpenHandleForUnzipping(HANDLE zip_handle) {
|
| zlib_filefunc_def zip_funcs;
|
| fill_win32_filefunc(&zip_funcs);
|
| zip_funcs.zopen_file = HandleOpenFileFunc;
|
| + zip_funcs.zclose_file = HandleCloseFileFunc;
|
| zip_funcs.opaque = zip_handle;
|
| return unzOpen2("fd", &zip_funcs);
|
| }
|
|
|