diff --git a/src/updatemanager.cpp b/src/updatemanager.cpp index c63a1d966e1..18ad9458d25 100644 --- a/src/updatemanager.cpp +++ b/src/updatemanager.cpp @@ -735,12 +735,14 @@ static bool cacheInfoIsUsable(CachePaths& paths) if (filesize <= 0) { // Invalid file size + PHYSFS_close(fileHandle); throw std::runtime_error("Invalid filesize"); } std::vector fileData(static_cast(filesize + 1), '\0'); if (WZ_PHYSFS_readBytes(fileHandle, fileData.data(), static_cast(filesize)) != filesize) { // Read failed + PHYSFS_close(fileHandle); throw std::runtime_error("Read failed"); } PHYSFS_close(fileHandle); @@ -791,12 +793,14 @@ static void initProcessData(const std::vector &updateDataUrls, Proc if (filesize < 0 || filesize > WZ_UPDATES_JSON_MAX_SIZE) { // Invalid file size + PHYSFS_close(fileHandle); throw std::runtime_error("Invalid filesize"); } std::vector fileData(static_cast(filesize + 1), '\0'); if (WZ_PHYSFS_readBytes(fileHandle, fileData.data(), static_cast(filesize)) != filesize) { // Read failed + PHYSFS_close(fileHandle); throw std::runtime_error("Read failed"); } PHYSFS_close(fileHandle);