From 7a27fcd249eb84edeacfb3866b0370c13facf0fd Mon Sep 17 00:00:00 2001 From: obligaron Date: Sat, 25 Jun 2022 17:32:08 +0200 Subject: [PATCH] Fix pfile_compare_hero_demo: Close MpqWriter before reading (for comparsion) --- Source/pfile.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/pfile.cpp b/Source/pfile.cpp index b631283b8..aa8ba725a 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -336,8 +336,10 @@ HeroCompareResult pfile_compare_hero_demo(int demo) return HeroCompareResult::ReferenceNotFound; std::string actualSavePath = GetSavePath(gSaveNumber, fmt::format("demo_{}_actual_", demo)); - auto saveWriter = MpqWriter(actualSavePath.c_str()); - pfile_write_hero(saveWriter, true); + { + MpqWriter saveWriter(actualSavePath.c_str()); + pfile_write_hero(saveWriter, true); + } bool compareResult = CompareSaves(actualSavePath, referenceSavePath); return compareResult ? HeroCompareResult::Same : HeroCompareResult::Difference;