added missing free and fclose in FileIndex

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8487 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-06-16 13:30:25 +00:00
parent 5e5dd3d12d
commit e3fdec4fba

View File

@ -823,6 +823,7 @@ int FileIndex::loadIndex(const std::string& filename, const RsFileHash& expected
if(!RsCompress::uncompress_memory_chunk(compressed_data,size,uncompressed_data,uncompressed_data_size)) if(!RsCompress::uncompress_memory_chunk(compressed_data,size,uncompressed_data,uncompressed_data_size))
{ {
std::cerr << "FileIndex::loadIndex() Decompression failed! Fileindex can't be read." << std::endl; std::cerr << "FileIndex::loadIndex() Decompression failed! Fileindex can't be read." << std::endl;
free(uncompressed_data);
return 0 ; return 0 ;
} }
s = std::string((char *)uncompressed_data,uncompressed_data_size) ; s = std::string((char *)uncompressed_data,uncompressed_data_size) ;
@ -1055,6 +1056,7 @@ int FileIndex::saveIndex(const std::string& filename, RsFileHash &fileHash, uint
if(!RsCompress::compress_memory_chunk((unsigned char *)s.c_str(),s.length(),compressed_data,compressed_data_size)) if(!RsCompress::compress_memory_chunk((unsigned char *)s.c_str(),s.length(),compressed_data,compressed_data_size))
{ {
std::cerr << "(EE) ERROR in file list compression ! file list can't be saved" << std::endl; std::cerr << "(EE) ERROR in file list compression ! file list can't be saved" << std::endl;
free(compressed_data);
return false ; return false ;
} }
@ -1092,6 +1094,7 @@ int FileIndex::saveIndex(const std::string& filename, RsFileHash &fileHash, uint
if(compressed_data_size != (outwritten=fwrite(compressed_data,1,compressed_data_size,file))) if(compressed_data_size != (outwritten=fwrite(compressed_data,1,compressed_data_size,file)))
{ {
std::cerr << "FileIndex::saveIndex error. File not entirely written. Only " << outwritten << " bytes wrote out of " << compressed_data_size << " check for disk full, or disk quotas." << std::endl; std::cerr << "FileIndex::saveIndex error. File not entirely written. Only " << outwritten << " bytes wrote out of " << compressed_data_size << " check for disk full, or disk quotas." << std::endl;
fclose(file);
return 0; return 0;
} }