From f1e726f5038174a07844418a2a18704acb855e01 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Wed, 10 May 2017 18:44:55 -0700 Subject: [PATCH] Don't dereference iterator in memory helpers if size == 0 --- include/tins/memory_helpers.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/tins/memory_helpers.h b/include/tins/memory_helpers.h index 81c8bc3..ec63eac 100644 --- a/include/tins/memory_helpers.h +++ b/include/tins/memory_helpers.h @@ -143,6 +143,10 @@ public: if (TINS_UNLIKELY(size_ < length)) { throw serialization_error(); } + // VC doesn't like dereferencing empty vector's iterators so check this here + if (TINS_UNLIKELY(length == 0)) { + return; + } std::memcpy(buffer_, &*start, length); skip(length); }