From 41675859dddce25ed772ac3a2e393a9524a74206 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sun, 6 Oct 2013 05:10:49 +0200 Subject: [PATCH] Actually destroy duplicated PHYSFS_Io instance on close Fixes crash after loading about a hundred maps --- src/filesystem.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 3cb26ef..eb6c21a 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -48,17 +48,18 @@ struct RGSS_entryHandle uint64_t currentOffset; PHYSFS_Io *io; - RGSS_entryHandle(const RGSS_entryData &data) + RGSS_entryHandle(const RGSS_entryData &data, PHYSFS_Io *archIo) : data(data), currentMagic(data.startMagic), currentOffset(0) - {} + { + io = archIo->duplicate(archIo); + } - RGSS_entryHandle(const RGSS_entryHandle &other) - : data(other.data), - currentMagic(other.currentMagic), - currentOffset(other.currentOffset) - {} + ~RGSS_entryHandle() + { + io->destroy(io); + } }; typedef QList QByteList; @@ -436,8 +437,8 @@ RGSS_openRead(void *opaque, const char *filename) if (!data->entryHash.contains(filename)) return 0; - RGSS_entryHandle *entry = new RGSS_entryHandle(data->entryHash[filename]); - entry->io = data->archiveIo->duplicate(data->archiveIo); + RGSS_entryHandle *entry = + new RGSS_entryHandle(data->entryHash[filename], data->archiveIo); PHYSFS_Io *io = PHYSFS_ALLOC(PHYSFS_Io);