this is a fix for the file download problem. It does not correct the wrong chunk size, but it checks that the malloc returns something.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1442 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-07-27 20:31:56 +00:00
parent 9834ef5cbf
commit c9467a2bfe
2 changed files with 15 additions and 1 deletions

View File

@ -415,6 +415,11 @@ bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider,
{
void *data = malloc(chunksize);
if(data == NULL)
{
std::cerr << "WARNING: Could not allocate data for a chunksize of " << chunksize << std::endl ;
return false ;
}
#ifdef MPLEX_DEBUG
std::cerr << "ftDataMultiplex::locked_handleServerRequest()";
std::cerr << "\t peer: " << peerId << " hash: " << hash;

View File

@ -100,7 +100,16 @@ bool ftFileProvider::getFileData(uint64_t offset, uint32_t &chunk_size, void *da
}
if (data_size > 0)
{
{
if(data == NULL)
{
std::cerr << "ftFileProvider: Warning ! Re-allocating data, which probably could not be allocated because of weird chunk size." << std::endl ;
if(NULL == (data = malloc(data_size)))
{
std::cerr << "ftFileProvider: Could not malloc a size of " << data_size << std::endl ;
return false;
}
}
/*
* seek for base_loc
*/