From 7258aea09be1847b3dcc99ca389990027d4a92d3 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 21 Oct 2014 03:33:47 +0000 Subject: tests: Assert on out-of-memory in tests This should never happen but can improve debugging experience for work-in-progress changes since that avoids memcpy() into negative memory space (debugger can't backtrace from failed memcpy since it does not set up the stack frame). git-svn-id: https://pugixml.googlecode.com/svn/trunk@1070 99668b35-9821-0410-8761-19e4c4f06640 --- tests/allocator.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/allocator.cpp') diff --git a/tests/allocator.cpp b/tests/allocator.cpp index 3641585..094d5e5 100644 --- a/tests/allocator.cpp +++ b/tests/allocator.cpp @@ -1,6 +1,7 @@ #include "allocator.hpp" #include +#include // Low-level allocation functions #if defined(_WIN32) || defined(_WIN64) @@ -97,6 +98,8 @@ void* memory_allocate(size_t size) size_t memory_size(void* ptr) { + assert(ptr); + size_t result; memcpy(&result, static_cast(ptr) - 1, sizeof(size_t)); -- cgit v1.2.3