fixed bug: re-allocation of local variable

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4659 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-11-02 13:58:33 +00:00
parent 3c2a5e8f42
commit e202a01862

View File

@ -162,17 +162,8 @@ bool ftFileProvider::getFileData(const std::string& peer_id,uint64_t offset, uin
std::cerr <<"Chunk Size greater than total file size, adjusting chunk size " << data_size << std::endl;
}
if (data_size > 0)
if(data_size > 0 && data != NULL)
{
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
*/
@ -221,7 +212,7 @@ bool ftFileProvider::getFileData(const std::string& peer_id,uint64_t offset, uin
}
else
{
std::cerr << "No data to read" << std::endl;
std::cerr << "No data to read, or NULL buffer used" << std::endl;
return 0;
}
return 1;