From 359ec2977ec93d2d04fb9bcadbfad6e69fbf1a3e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 4 Jul 2014 15:39:35 +0100 Subject: Fix fopen call and throw an exception if it fails. --- src/subtitle_content.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc index 7e11dea4..5a45d737 100644 --- a/src/subtitle_content.cc +++ b/src/subtitle_content.cc @@ -238,7 +238,11 @@ struct SubtitleSorter { void SubtitleContent::write_xml (boost::filesystem::path p) const { - FILE* f = fopen_boost (p, "r"); + FILE* f = fopen_boost (p, "w"); + if (!f) { + throw FileError ("Could not open file for writing", p, -1); + } + Glib::ustring const s = xml_as_string (); fwrite (s.c_str(), 1, s.length(), f); fclose (f); -- cgit v1.2.3