From 330c04724e9e6a8a173ed1a190de59c36f941fde Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 24 Jul 2024 21:34:47 +0200 Subject: [PATCH] #268: Move delete to the bottom of deserializeType function --- src/checkpoint/dispatch/dispatch.impl.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/checkpoint/dispatch/dispatch.impl.h b/src/checkpoint/dispatch/dispatch.impl.h index efa3d659..fc6a5dc3 100644 --- a/src/checkpoint/dispatch/dispatch.impl.h +++ b/src/checkpoint/dispatch/dispatch.impl.h @@ -342,9 +342,7 @@ deserializeType(SerialByteType* data, SerialByteType* allocBuf) { auto prefix_struct = PrefixedType(prefix_buf); // Disable memory check during first unpacking. // Unpacking BaseType will always result in memory amount missmatch between serialization/deserialization - auto* prefix = - Standard::unpack>(&prefix_struct, data, false); - delete prefix_buf; + auto* prefix = Standard::unpack>(&prefix_struct, data, false); validatePrefix(prefix->prefix_); @@ -352,8 +350,9 @@ deserializeType(SerialByteType* data, SerialByteType* allocBuf) { auto mem = allocBuf ? allocBuf : vrt::objregistry::allocateConcreteType(prefix->prefix_); auto t_buf = vrt::objregistry::constructConcreteType(prefix->prefix_, mem); auto prefixed = PrefixedType(t_buf); - auto* traverser = - Standard::unpack>(&prefixed, data); + auto* traverser = Standard::unpack>(&prefixed, data); + + delete prefix_buf; return static_cast(traverser->target_); }