From 464d0f4ff9e6d30be6a5ccf9da571ce8596840fd Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 9 May 2010 17:53:59 +0000 Subject: Added empty stream/buffer tests, fixed null buffer parsing in wchar_t mode git-svn-id: http://pugixml.googlecode.com/svn/trunk@397 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') 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(contents); - out_buffer = is_mutable ? const_cast(data) : static_cast(global_allocate(size > 0 ? size : 1)); - out_length = size / sizeof(char_t); + if (is_mutable) + { + out_buffer = const_cast(data); + } + else + { + out_buffer = static_cast(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); -- cgit v1.2.3