fixed a few serialisation issues

This commit is contained in:
Cyril Soler 2016-01-13 12:22:55 -05:00
parent 96f3446aa7
commit 086b076477
2 changed files with 14 additions and 3 deletions

View File

@ -349,6 +349,12 @@ RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const
if(data_size > 0) if(data_size > 0)
{ {
item->data_bytes = (uint8_t*)rs_malloc(data_size) ; item->data_bytes = (uint8_t*)rs_malloc(data_size) ;
if(item->data_bytes == NULL)
{
delete item ;
return NULL ;
}
memcpy(item->data_bytes,data_bytes,data_size) ; memcpy(item->data_bytes,data_bytes,data_size) ;
} }
else else

View File

@ -284,16 +284,21 @@ RsTurtleRegExpSearchRequestItem::RsTurtleRegExpSearchRequestItem(void *data,uint
uint32_t n =0 ; uint32_t n =0 ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ; ok &= getRawUInt32(data,pktsize,&offset,&n) ;
if(ok)
expr._tokens.resize(n) ; expr._tokens.resize(n) ;
for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt8(data,pktsize,&offset,&expr._tokens[i]) ; for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt8(data,pktsize,&offset,&expr._tokens[i]) ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ; ok &= getRawUInt32(data,pktsize,&offset,&n) ;
if(ok)
expr._ints.resize(n) ; expr._ints.resize(n) ;
for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt32(data,pktsize,&offset,&expr._ints[i]) ; for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt32(data,pktsize,&offset,&expr._ints[i]) ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ; ok &= getRawUInt32(data,pktsize,&offset,&n) ;
if(ok)
expr._strings.resize(n) ; expr._strings.resize(n) ;
for(uint32_t i=0;i<n && ok;++i) ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_VALUE, expr._strings[i]); for(uint32_t i=0;i<n && ok;++i) ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_VALUE, expr._strings[i]);