summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-02-22 02:57:15 +0000
committerrubidium <rubidium@openttd.org>2009-02-22 02:57:15 +0000
commit54f852f0948a686ae6d213f907310e358a1f1fb4 (patch)
tree379b3afc640f578ec71255abc9ec4b97972c91ab /src/network
parent731c1e90e85fbc48c59a6c94e293ca211083b1e6 (diff)
downloadopenttd-54f852f0948a686ae6d213f907310e358a1f1fb4.tar.xz
(svn r15552) -Fix (r15544): some compiler/OS combinations don't like closing the same FD twice and zlib's docs weren't very clear about whether it would close a FD it didn't open.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_content.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 7f6dd75ae..42077ca08 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -324,8 +324,14 @@ static bool GunzipFile(const ContentInfo *ci)
}
exit:
- if (fin != NULL) gzclose(fin);
- if (ftmp != NULL) fclose(ftmp);
+ if (fin != NULL) {
+ /* Closes ftmp too! */
+ gzclose(fin);
+ } else if (ftmp != NULL) {
+ /* In case the gz stream was opened correctly this will
+ * be closed by gzclose. */
+ fclose(ftmp);
+ }
if (fout != NULL) fclose(fout);
return ret;