From 1de5fc1419add86884df97580d7a2e745ad43bff Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 29 Jun 2015 14:02:37 +0200 Subject: More changes for use with debug STL --- src/lib/alloc/secmem.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/lib/alloc') diff --git a/src/lib/alloc/secmem.h b/src/lib/alloc/secmem.h index b583aa812..98707ad4e 100644 --- a/src/lib/alloc/secmem.h +++ b/src/lib/alloc/secmem.h @@ -108,7 +108,10 @@ size_t buffer_insert(std::vector& buf, size_t input_length) { const size_t to_copy = std::min(input_length, buf.size() - buf_offset); - copy_mem(&buf[buf_offset], input, to_copy); + if (to_copy > 0) + { + copy_mem(&buf[buf_offset], input, to_copy); + } return to_copy; } @@ -118,7 +121,10 @@ size_t buffer_insert(std::vector& buf, const std::vector& input) { const size_t to_copy = std::min(input.size(), buf.size() - buf_offset); - copy_mem(&buf[buf_offset], input.data(), to_copy); + if (to_copy > 0) + { + copy_mem(&buf[buf_offset], input.data(), to_copy); + } return to_copy; } @@ -129,7 +135,10 @@ operator+=(std::vector& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.size()); - copy_mem(&out[copy_offset], in.data(), in.size()); + if (in.size() > 0) + { + copy_mem(&out[copy_offset], in.data(), in.size()); + } return out; } @@ -146,7 +155,10 @@ std::vector& operator+=(std::vector& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.second); - copy_mem(&out[copy_offset], in.first, in.second); + if (in.second > 0) + { + copy_mem(&out[copy_offset], in.first, in.second); + } return out; } @@ -156,7 +168,10 @@ std::vector& operator+=(std::vector& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.second); - copy_mem(&out[copy_offset], in.first, in.second); + if (in.second > 0) + { + copy_mem(&out[copy_offset], in.first, in.second); + } return out; } -- cgit v1.2.3