summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/package.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-10-07 00:21:22 +0200
committerAdam Borowski <kilobyte@angband.pl>2010-10-07 00:35:26 +0200
commit30be6f76d84ae4a9254f2307f7fcb19d144e5fb5 (patch)
treeb577a233d96f44a5c52045f5524b3a6598d02f1f /crawl-ref/source/package.cc
parent2d20a979dd95b082f58486da06bdb8340ceeb675 (diff)
downloadcrawl-ref-30be6f76d84ae4a9254f2307f7fcb19d144e5fb5.tar.gz
crawl-ref-30be6f76d84ae4a9254f2307f7fcb19d144e5fb5.zip
Fix a memory leak on failed writes.
Actually, I can't think of a case where such error won't be fatal, but then, it leaves Crawl in a consistent state so we might in theory merely return to menu (restart_after_game). I'm fixing it mostly in case someone reuses the transactional packager for some purpose other than Crawl.
Diffstat (limited to 'crawl-ref/source/package.cc')
-rw-r--r--crawl-ref/source/package.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/crawl-ref/source/package.cc b/crawl-ref/source/package.cc
index be98d610ca..bbe374df5c 100644
--- a/crawl-ref/source/package.cc
+++ b/crawl-ref/source/package.cc
@@ -586,7 +586,13 @@ chunk_writer::~chunk_writer()
ASSERT(pkg->n_users > 0);
pkg->n_users--;
if (pkg->aborted)
+ {
+#ifdef USE_ZLIB
+ // ignore errors, they're not relevant anymore
+ deflateEnd(&zs);
+#endif
return;
+ }
#ifdef USE_ZLIB
zs.avail_in = 0;