From 913ff622a4c7c9162666d496ad9fd083722e3742 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 21 Oct 2012 15:21:24 -0700 Subject: [PATCH] Verify that creating the temp file for saving actually succeeded --- aegisub/libaegisub/common/io.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aegisub/libaegisub/common/io.cpp b/aegisub/libaegisub/common/io.cpp index 112045749..4992f6934 100644 --- a/aegisub/libaegisub/common/io.cpp +++ b/aegisub/libaegisub/common/io.cpp @@ -78,10 +78,14 @@ Save::Save(const std::string& file, bool binary) // If the file doesn't exist we create a 0 byte file, this so so // util::Rename will find it, and to let users know something went // wrong by leaving a 0 byte file. - std::ofstream fp_touch(ConvertW(file).c_str()); + std::ofstream(ConvertW(file).c_str()); } fp = new std::ofstream(ConvertW(tmp_name).c_str(), binary ? std::ios::binary : std::ios::out); + if (!fp->good()) { + delete fp; + throw agi::FileNotAccessibleError("Could not create temporary file at: " + tmp_name); + } } Save::~Save() {