summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/package.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-01-07 14:13:48 +0100
committerAdam Borowski <kilobyte@angband.pl>2011-01-07 14:13:48 +0100
commitd78b096eb75fff2fc7dcaa00d09d18360d8fc3b8 (patch)
tree1964d77af3de432c4989c4f145cd74b42df22546 /crawl-ref/source/package.cc
parent95d7f0cd5adbcf230d64aa2ee1ecda8ce9c80768 (diff)
downloadcrawl-ref-d78b096eb75fff2fc7dcaa00d09d18360d8fc3b8.tar.gz
crawl-ref-d78b096eb75fff2fc7dcaa00d09d18360d8fc3b8.zip
Fix a memory leak and potential crash on browsing corrupted saves.
Diffstat (limited to 'crawl-ref/source/package.cc')
-rw-r--r--crawl-ref/source/package.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/crawl-ref/source/package.cc b/crawl-ref/source/package.cc
index cc77785f01..90dcd9fc98 100644
--- a/crawl-ref/source/package.cc
+++ b/crawl-ref/source/package.cc
@@ -463,10 +463,10 @@ void package::read_directory(len_t start, uint8_t version)
directory[""] = start;
dprintf("package: reading directory\n");
- chunk_reader *rd = new chunk_reader(this, start);
+ chunk_reader rd(this, start);
dir_entry ch;
- while(len_t res = rd->read(&ch, sizeof(dir_entry)))
+ while(len_t res = rd.read(&ch, sizeof(dir_entry)))
{
if (res != sizeof(dir_entry))
fail("save file corrupted -- truncated directory");
@@ -475,8 +475,6 @@ void package::read_directory(len_t start, uint8_t version)
directory[chname] = htole(ch.start);
dprintf("* %s\n", chname.c_str());
}
-
- delete rd;
}
bool package::has_chunk(const std::string name)