From 2e4f6c54a879a625e57cf6a679e2fa7bd3810730 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Sat, 8 Dec 2012 04:06:37 +0000 Subject: Work around clang static analysis false positives using extra assertions. git-svn-id: http://pugixml.googlecode.com/svn/trunk@943 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index c1720f1..37c7c02 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -323,6 +323,7 @@ PUGI__NS_BEGIN // prepare page structure xml_memory_page* page = xml_memory_page::construct(page_memory); + assert(page); page->memory = memory; page->allocator = _root->allocator; @@ -1550,6 +1551,8 @@ PUGI__NS_BEGIN PUGI__FN bool strcpy_insitu(char_t*& dest, uintptr_t& header, uintptr_t header_mask, const char_t* source) { + assert(header); + size_t source_length = strlength(source); if (source_length == 0) @@ -1882,7 +1885,7 @@ PUGI__NS_BEGIN case 1: return strconv_pcdata_impl::parse; case 2: return strconv_pcdata_impl::parse; case 3: return strconv_pcdata_impl::parse; - default: return 0; // should not get here + default: assert(false); return 0; // should not get here } } @@ -2059,7 +2062,7 @@ PUGI__NS_BEGIN case 13: return strconv_attribute_impl::parse_wnorm; case 14: return strconv_attribute_impl::parse_wnorm; case 15: return strconv_attribute_impl::parse_wnorm; - default: return 0; // should not get here + default: assert(false); return 0; // should not get here } } @@ -5225,6 +5228,7 @@ namespace pugi // prepare page structure impl::xml_memory_page* page = impl::xml_memory_page::construct(page_memory); + assert(page); page->busy_size = impl::xml_memory_page_size; @@ -8843,6 +8847,7 @@ PUGI__NS_BEGIN char_t* c = static_cast(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); if (!c) throw_error_oom(); + assert(c); // workaround for clang static analysis memcpy(c, value.begin, length * sizeof(char_t)); c[length] = 0; -- cgit v1.2.3