mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
added doubling of buffer size in checkSectionSize when missing space. Used 1024 instead of 1000 as start size
This commit is contained in:
parent
5fbc263a36
commit
d975a18fd6
@ -54,4 +54,4 @@ static const uint32_t NB_ENTRY_INDEX_BITS = 22 ; // Do not
|
|||||||
static const uint32_t ENTRY_INDEX_BIT_MASK = 0x003fffff ; // used for storing (EntryIndex,Friend) couples into a 32bits pointer. Depends on the two values just before. Dont change!
|
static const uint32_t ENTRY_INDEX_BIT_MASK = 0x003fffff ; // used for storing (EntryIndex,Friend) couples into a 32bits pointer. Depends on the two values just before. Dont change!
|
||||||
static const uint32_t DELAY_BEFORE_DROP_REQUEST = 600; // every 10 min
|
static const uint32_t DELAY_BEFORE_DROP_REQUEST = 600; // every 10 min
|
||||||
|
|
||||||
static const uint32_t FL_BASE_TMP_SECTION_SIZE = 1000 ;
|
static const uint32_t FL_BASE_TMP_SECTION_SIZE = 4096 ;
|
||||||
|
@ -109,14 +109,27 @@ private:
|
|||||||
|
|
||||||
static bool checkSectionSize(unsigned char *& buff,uint32_t& buff_size,uint32_t offset,uint32_t S)
|
static bool checkSectionSize(unsigned char *& buff,uint32_t& buff_size,uint32_t offset,uint32_t S)
|
||||||
{
|
{
|
||||||
|
// This tests avoids an infinite loop when growing new size
|
||||||
|
|
||||||
|
if(offset + S + SECTION_HEADER_MAX_SIZE > 0x8fffffff)
|
||||||
|
return false ;
|
||||||
|
|
||||||
if(offset + S + SECTION_HEADER_MAX_SIZE > buff_size)
|
if(offset + S + SECTION_HEADER_MAX_SIZE > buff_size)
|
||||||
{
|
{
|
||||||
buff = (unsigned char *)realloc(buff,offset + S + SECTION_HEADER_MAX_SIZE) ;
|
uint32_t new_size = (buff_size == 0)?512:buff_size ;
|
||||||
buff_size = offset + S + SECTION_HEADER_MAX_SIZE;
|
|
||||||
|
while(new_size < offset + S + SECTION_HEADER_MAX_SIZE)
|
||||||
|
new_size <<= 1 ;
|
||||||
|
|
||||||
|
buff = (unsigned char *)realloc(buff,new_size) ;
|
||||||
|
|
||||||
if(!buff)
|
if(!buff)
|
||||||
|
{
|
||||||
|
buff_size = 0 ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
buff_size = new_size ;
|
||||||
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user