From 60408b3799a322457d4f3e42d8aad523505b2688 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 13 Jan 2016 00:13:16 -0500 Subject: [PATCH] fixed a bug in GRouterGenericDataItem::duplicate() --- libretroshare/src/grouter/grouteritems.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/grouter/grouteritems.cc b/libretroshare/src/grouter/grouteritems.cc index aa077b590..4f85bd429 100644 --- a/libretroshare/src/grouter/grouteritems.cc +++ b/libretroshare/src/grouter/grouteritems.cc @@ -346,12 +346,13 @@ RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const // then duplicate the memory chunk - item->data_bytes = (uint8_t*)rs_malloc(data_size) ; - - if(item->data_bytes == NULL) - return NULL ; - - memcpy(item->data_bytes,data_bytes,data_size) ; + if(data_size > 0) + { + item->data_bytes = (uint8_t*)rs_malloc(data_size) ; + memcpy(item->data_bytes,data_bytes,data_size) ; + } + else + item->data_bytes = NULL ; return item ; }