aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2022-10-09 09:08:50 -0700
committerGitHub <noreply@github.com>2022-10-09 09:08:50 -0700
commit86c91051541d18a0d24b837a866cf0306fc8db1a (patch)
tree079031cea961a2f10275e6b076ae5eea88eb8eac
parent0cb4f025791f7c17f8ec09a1c12b0cb107518fad (diff)
parent444963e2690d0a2a05df62429379e633e1dfb1d4 (diff)
downloadpugixml-86c91051541d18a0d24b837a866cf0306fc8db1a.zip
pugixml-86c91051541d18a0d24b837a866cf0306fc8db1a.tar.gz
pugixml-86c91051541d18a0d24b837a866cf0306fc8db1a.tar.bz2
Merge pull request #523 from zeux/ferrh
Fix error handling in xml_document::save_file
-rw-r--r--src/pugixml.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 6b16dbb..7c84038 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5070,7 +5070,7 @@ PUGI__NS_BEGIN
xml_writer_file writer(file);
doc.save(writer, indent, flags, encoding);
- return ferror(file) == 0;
+ return fflush(file) == 0 && ferror(file) == 0;
}
struct name_null_sentry
@@ -7423,7 +7423,7 @@ namespace pugi
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);
- return impl::save_file_impl(*this, file.data, indent, flags, encoding);
+ return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}
PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
@@ -7431,7 +7431,7 @@ namespace pugi
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), impl::close_file);
- return impl::save_file_impl(*this, file.data, indent, flags, encoding);
+ return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}
PUGI__FN xml_node xml_document::document_element() const