diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 642293ab..4d138ab8 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -133,7 +133,8 @@ jobs: release_name: Release ${{ env.RELEASE_VERSION }} body: | # Changes in this Release - - **FIX** Properly handle UNC paths + - **FIX** Fix memory and handle leak when encountering empty folders + - **FIX** Fix reallocation size when scanning folders draft: false prerelease: false files: "*-x64.zip" diff --git a/lib/compressblockstore/longtail_compressblockstore.c b/lib/compressblockstore/longtail_compressblockstore.c index d2278f7f..06231070 100644 --- a/lib/compressblockstore/longtail_compressblockstore.c +++ b/lib/compressblockstore/longtail_compressblockstore.c @@ -315,7 +315,7 @@ static int DecompressBlock( LONGTAIL_FATAL_ASSERT(ctx, uncompressed_stored_block->m_BlockIndex, return EINVAL; ) uncompressed_stored_block->m_BlockData = &((uint8_t*)(&uncompressed_stored_block->m_BlockIndex[1]))[block_index_data_size]; uncompressed_stored_block->m_BlockChunksDataSize = uncompressed_size; - memmove(&uncompressed_stored_block->m_BlockIndex[1], &compressed_stored_block->m_BlockIndex[1], block_index_data_size); + memmove(&uncompressed_stored_block->m_BlockIndex[1], ((const uint8_t*)(compressed_stored_block->m_BlockData))-block_index_data_size, block_index_data_size); size_t real_uncompressed_size = 0; err = compression_api->Decompress( diff --git a/lib/longtail_platform.c b/lib/longtail_platform.c index f8ef6641..82f61769 100644 --- a/lib/longtail_platform.c +++ b/lib/longtail_platform.c @@ -576,7 +576,13 @@ int Longtail_StartFind(HLongtail_FSIterator fs_iterator, const char* path) Longtail_Free(fs_iterator->m_Path); return Win32ErrorToErrno(GetLastError()); } - return Skip(fs_iterator); + int err = Skip(fs_iterator); + if (err != 0) + { + FindClose(fs_iterator->m_Handle); + Longtail_Free(fs_iterator->m_Path); + } + return err; } int Longtail_FindNext(HLongtail_FSIterator fs_iterator) diff --git a/src/longtail.c b/src/longtail.c index 66997e12..c4367406 100644 --- a/src/longtail.c +++ b/src/longtail.c @@ -1585,7 +1585,7 @@ static int AddFile(void* context, const char* root_path, const char* asset_path, full_path[asset_path_length + 1] = 0; } - int err = AppendPath(&paths_context->m_FileInfos, full_path, properties->m_Size, properties->m_Permissions, &paths_context->m_ReservedPathCount, &paths_context->m_ReservedPathSize, 512, 128); + int err = AppendPath(&paths_context->m_FileInfos, full_path, properties->m_Size, properties->m_Permissions, &paths_context->m_ReservedPathCount, &paths_context->m_ReservedPathSize, 1024, 1024 * 32); if (err) { LONGTAIL_LOG(ctx, LONGTAIL_LOG_LEVEL_ERROR, "AppendPath() failed with %d", err) @@ -3293,8 +3293,9 @@ int Longtail_InitStoredBlockFromData( LONGTAIL_LOG(ctx, LONGTAIL_LOG_LEVEL_ERROR, "Longtail_InitBlockIndexFromData() failed with %d", err) return err; } - stored_block->m_BlockData = &((uint8_t*)stored_block->m_BlockIndex)[Longtail_GetBlockIndexSize(*stored_block->m_BlockIndex->m_ChunkCount)]; - stored_block->m_BlockChunksDataSize = (uint32_t)(block_data_size - Longtail_GetBlockIndexDataSize(*stored_block->m_BlockIndex->m_ChunkCount)); + size_t BlockIndexDataSize = Longtail_GetBlockIndexDataSize(*stored_block->m_BlockIndex->m_ChunkCount); + stored_block->m_BlockData = &((uint8_t*)block_data)[BlockIndexDataSize]; + stored_block->m_BlockChunksDataSize = (uint32_t)(block_data_size - BlockIndexDataSize); stored_block->Dispose = 0; return 0; }