From e202a0186291e1f2cb41c0f1bb05a68c7ae58152 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 2 Nov 2011 13:58:33 +0000 Subject: [PATCH] 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 --- libretroshare/src/ft/ftfileprovider.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libretroshare/src/ft/ftfileprovider.cc b/libretroshare/src/ft/ftfileprovider.cc index 08cc3b4e9..a95b7864f 100644 --- a/libretroshare/src/ft/ftfileprovider.cc +++ b/libretroshare/src/ft/ftfileprovider.cc @@ -162,20 +162,11 @@ 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 - */ + * seek for base_loc + */ fseeko64(fd, base_loc, SEEK_SET); // Data space allocated by caller. @@ -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;