From 0eb35418e83c0304b4876bc7b400196fd868694f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 19 May 2015 21:48:23 -0400 Subject: [PATCH] Catch exceptions when opening recovery files so we don't crash on corrupt files --- src/AutoRecovery.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp index 9711d7de0..b04997618 100755 --- a/src/AutoRecovery.cpp +++ b/src/AutoRecovery.cpp @@ -694,10 +694,21 @@ bool AutoSaveFile::Decode(const wxString & fileName) // Decode to a temporary file to preserve the orignal. wxString tempName = fn.CreateTempFileName(fn.GetPath()); + bool opened = false; + XMLFileWriter out; - out.Open(tempName, wxT("wb")); - if (!out.IsOpened()) + try + { + out.Open(tempName, wxT("wb")); + opened = out.IsOpened(); + } + catch (XMLFileWriterException* pException) + { + delete pException; + } + + if (!opened) { delete[] buf;