diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 795eafe3..4a64ff77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,9 @@ jobs: cmake --build build tree -sha build - name: Test - run: ASAN_OPTIONS=detect_leaks=0 LSAN_OPTIONS=verbosity=1:log_threads=1 cmake --build build --target test + run: | + cd build + ASAN_OPTIONS=detect_leaks=0 LSAN_OPTIONS=verbosity=1:log_threads=1 CTEST_OUTPUT_ON_FAILURE=1 ctest -VV --output-on-failure macos: runs-on: macos-latest @@ -33,7 +35,9 @@ jobs: cmake --build build tree -sha build - name: Test - run: cmake --build build --target test + run: | + cd build + CTEST_OUTPUT_ON_FAILURE=1 ctest -VV --output-on-failure # freebsd: # runs-on: macos-latest @@ -63,7 +67,7 @@ jobs: - name: Test run: | cd build - ctest -VV -C "Debug" + ctest -VV -C "Debug" --output-on-failure windows-mingw: runs-on: "windows-latest" @@ -76,4 +80,6 @@ jobs: cmake --build build tree /a /f build - name: Test - run: cmake --build build --target test + run: | + cd build + ctest -VV -C "Debug" --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f10e0c1..685f6f93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.17) project(zip LANGUAGES C diff --git a/src/zip.h b/src/zip.h index 324904ca..25ac3916 100644 --- a/src/zip.h +++ b/src/zip.h @@ -446,7 +446,8 @@ zip_stream_extract(const char *stream, size_t size, const char *dir, /** * Opens zip archive stream into memory. * - * @param stream zip archive stream. + * @param stream zip archive stream. If not NULL, + * stream will be freed on zip_stream_close. * @param size stream size. * @param level compression level (0-9 are the standard zlib-style levels). * @param mode file access mode. @@ -494,6 +495,9 @@ extern ZIP_EXPORT ssize_t zip_stream_copy(struct zip_t *zip, void **buf, /** * Close zip archive releases resources. * + * If a buffer was provided to zip_stream_open, + * it will be unallocated here. + * * @param zip zip archive handler. * * @return diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a8d7cab..5dae8aa6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.17) find_package(Sanitizers) diff --git a/test/test_entry.c b/test/test_entry.c index 7fae49d8..009f07b6 100644 --- a/test/test_entry.c +++ b/test/test_entry.c @@ -424,8 +424,8 @@ MU_TEST(test_entries_delete_stream) { zip_stream_copy(zip, (void **)&modified_zdata, &zsize); mu_check(modified_zdata != NULL); + // Note that zip_stream_close will free the zdata passed in zip_stream_open zip_stream_close(zip); - free(zdata); zdata = NULL; zip = zip_stream_open(modified_zdata, zsize, 0, 'r');