diff --git a/simgear/io/HTTPRepository.cxx b/simgear/io/HTTPRepository.cxx index 2c1c61c6..acac1cf8 100644 --- a/simgear/io/HTTPRepository.cxx +++ b/simgear/io/HTTPRepository.cxx @@ -749,6 +749,10 @@ HTTPRepository::failure() const code = HTTPRepository::REPO_ERROR_CANCELLED; } + if (file) { + file->close(); + } + file.reset(); if (pathInRepo.exists()) { pathInRepo.remove(); diff --git a/simgear/io/sg_file.hxx b/simgear/io/sg_file.hxx index 8385c8b3..613f097c 100644 --- a/simgear/io/sg_file.hxx +++ b/simgear/io/sg_file.hxx @@ -62,7 +62,7 @@ public: SGFile( int existingFd ); /** Destructor */ - ~SGFile(); + virtual ~SGFile(); // open the file based on specified direction bool open( const SGProtocolDir dir ); diff --git a/simgear/io/test_repository.cxx b/simgear/io/test_repository.cxx index 07ba9728..666ff5c9 100644 --- a/simgear/io/test_repository.cxx +++ b/simgear/io/test_repository.cxx @@ -309,7 +309,8 @@ std::string test_computeHashForPath(const SGPath& p) return std::string(); sha1nfo info; sha1_init(&info); - char* buf = static_cast(alloca(1024 * 1024)); + char* buf = static_cast(malloc(1024 * 1024)); + assert(buf); size_t readLen; SGBinaryFile f(p); @@ -319,6 +320,9 @@ std::string test_computeHashForPath(const SGPath& p) sha1_write(&info, buf, readLen); } + f.close(); + free(buf); + std::string hashBytes((char*) sha1_result(&info), HASH_LENGTH); return strutils::encodeHex(hashBytes); } @@ -725,7 +729,7 @@ void testCopyInstalledChildren(HTTP::Client* cl) verifyRequestCount("dirJ/fileJC", 1); verifyRequestCount("dirJ/fileJD", 1); - std::cout << "Copy installed children" << std::endl; + std::cout << "passed Copy installed children" << std::endl; } int main(int argc, char* argv[])