summaryrefslogtreecommitdiff
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
commit5c127d51b8bb0606d08e4af57dfd8081da4ac880 (patch)
tree379b3afc640f578ec71255abc9ec4b97972c91ab
parentc2658c1105d20b5c7f68da7ee0ac0e7dcecaced7 (diff)
downloadopenttd-5c127d51b8bb0606d08e4af57dfd8081da4ac880.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.
-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;