Fixed possible crash in ServiceControlSerialiser by checking return value of dynamic_cast.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8593 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-07-12 01:02:43 +00:00
parent 63d85f8077
commit 014e78dd8c

View File

@ -188,11 +188,21 @@ public:
virtual uint32_t size (RsItem *item) virtual uint32_t size (RsItem *item)
{ {
return dynamic_cast<RsServiceControlItem *>(item)->serial_size() ; RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
if (!scitem)
{
return 0;
}
return scitem->serial_size() ;
} }
virtual bool serialise(RsItem *item, void *data, uint32_t *size) virtual bool serialise(RsItem *item, void *data, uint32_t *size)
{ {
return dynamic_cast<RsServiceControlItem *>(item)->serialise((uint8_t*)data,*size) ; RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
if (!scitem)
{
return false;
}
return scitem->serialise((uint8_t*)data,*size) ;
} }
virtual RsItem *deserialise (void *data, uint32_t *size) virtual RsItem *deserialise (void *data, uint32_t *size)
{ {