summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 37f52fc..27c2960 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -922,10 +922,17 @@ namespace
{
const char_t* data = static_cast<const char_t*>(contents);
- out_buffer = is_mutable ? const_cast<char_t*>(data) : static_cast<char_t*>(global_allocate(size > 0 ? size : 1));
- out_length = size / sizeof(char_t);
+ if (is_mutable)
+ {
+ out_buffer = const_cast<char_t*>(data);
+ }
+ else
+ {
+ out_buffer = static_cast<char_t*>(global_allocate(size > 0 ? size : 1));
+ if (!out_buffer) return false;
+ }
- if (!out_buffer) return false;
+ out_length = size / sizeof(char_t);
impl::convert_wchar_endian_swap(out_buffer, data, out_length);