mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 05:14:31 -04:00
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:
parent
9834ef5cbf
commit
c9467a2bfe
2 changed files with 15 additions and 1 deletions
|
@ -415,6 +415,11 @@ bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider,
|
||||||
{
|
{
|
||||||
void *data = malloc(chunksize);
|
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
|
#ifdef MPLEX_DEBUG
|
||||||
std::cerr << "ftDataMultiplex::locked_handleServerRequest()";
|
std::cerr << "ftDataMultiplex::locked_handleServerRequest()";
|
||||||
std::cerr << "\t peer: " << peerId << " hash: " << hash;
|
std::cerr << "\t peer: " << peerId << " hash: " << hash;
|
||||||
|
|
|
@ -101,6 +101,15 @@ bool ftFileProvider::getFileData(uint64_t offset, uint32_t &chunk_size, void *da
|
||||||
|
|
||||||
if (data_size > 0)
|
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
|
* seek for base_loc
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue