mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-19 03:18:15 -04:00
fixed a big memory leak in hash cache storage load code, and improved deletion of allocated memory if file reading fails
This commit is contained in:
parent
7861b092c3
commit
0a02419a29
3 changed files with 43 additions and 34 deletions
|
@ -59,16 +59,16 @@ bool FileListIO::writeField( unsigned char*&buff,uint32_t& buff_size,uint32
|
|||
|
||||
bool FileListIO::readField (const unsigned char *buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag, unsigned char *& val,uint32_t& size)
|
||||
{
|
||||
if(!readSectionHeader(buff,buff_size,offset,check_section_tag,size))
|
||||
uint32_t local_size ;
|
||||
|
||||
if(!readSectionHeader(buff,buff_size,offset,check_section_tag,local_size))
|
||||
return false;
|
||||
|
||||
val = (unsigned char *)rs_malloc(size) ;
|
||||
|
||||
if(!val)
|
||||
if(!checkSectionSize(val,size,0,local_size)) // allocate val if needed to handle local_size bytes.
|
||||
return false;
|
||||
|
||||
memcpy(val,&buff[offset],size);
|
||||
offset += size ;
|
||||
memcpy(val,&buff[offset],local_size);
|
||||
offset += local_size ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue