mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
fixed potential crash in pqisslstore
This commit is contained in:
parent
70bf938654
commit
9b64b96811
@ -391,18 +391,19 @@ bool pqiSSLstore::encryptedSendItems(const std::list<RsItem*>& rsItemList)
|
||||
std::list<RsItem*>::const_iterator it;
|
||||
uint32_t sizeItems = 0, sizeItem = 0;
|
||||
uint32_t offset = 0;
|
||||
char* data = NULL;
|
||||
|
||||
for(it = rsItemList.begin(); it != rsItemList.end(); ++it)
|
||||
if(*it != NULL)
|
||||
sizeItems += rsSerialiser->size(*it);
|
||||
|
||||
data = new char[sizeItems];
|
||||
RsTemporaryMemory data(sizeItems) ;
|
||||
|
||||
for(it = rsItemList.begin(); it != rsItemList.end(); ++it)
|
||||
if(*it != NULL)
|
||||
{
|
||||
sizeItem = rsSerialiser->size(*it);
|
||||
|
||||
if(rsSerialiser->serialise(*it, (data+offset),&sizeItem))
|
||||
if(rsSerialiser->serialise(*it, &data[offset],&sizeItem))
|
||||
offset += sizeItem;
|
||||
else
|
||||
std::cerr << "(EE) pqiSSLstore::encryptedSendItems(): One item did not serialize. The item is probably unknown from the serializer. Dropping the item. " << std::endl;
|
||||
@ -418,9 +419,6 @@ bool pqiSSLstore::encryptedSendItems(const std::list<RsItem*>& rsItemList)
|
||||
else
|
||||
result = false;
|
||||
|
||||
if(data != NULL)
|
||||
delete[] data;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user