From 684858e7b7924d7789395ec5950d4b29315a4516 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Tue, 21 Feb 2017 18:17:24 +0100 Subject: [PATCH] fix memory leaks --- .travis.yml | 15 +-------------- contrib/pzstd/Makefile | 17 +++++++++++++++++ programs/zstdcli.c | 4 ++-- tests/zstreamtest.c | 2 ++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7379fc50..38ed2343 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,14 +8,6 @@ matrix: # Container-based Ubuntu 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes) - - env: Ubu=12.04cont Cmd="make usan" - os: linux - sudo: false - - - env: Ubu=12.04cont Cmd="make asan" - os: linux - sudo: false - - env: Ubu=12.04cont Cmd="make uasan" os: linux sudo: false @@ -46,17 +38,12 @@ matrix: # Ubuntu 14.04 LTS Server Edition 64 bit - - env: Ubu=14.04 Cmd='cd contrib/pzstd && make googletest pzstd tests check && make clean - && make googletest32 all32 check && make clean - && make googletest tsan check && make clean - && make asan check && make clean' + - env: Ubu=14.04 Cmd='cd contrib/pzstd && make test-pzstd && make test-pzstd32 && make test-pzstd-tsan && test-pzstd-asan' os: linux dist: trusty sudo: required install: - export CXX="g++-6" CC="gcc-6" - - export LDFLAGS="-fuse-ld=gold" - - export TESTFLAGS='--gtest_filter=-*ExtremelyLarge*' addons: apt: sources: diff --git a/contrib/pzstd/Makefile b/contrib/pzstd/Makefile index f148bfd8..10a133dd 100644 --- a/contrib/pzstd/Makefile +++ b/contrib/pzstd/Makefile @@ -85,6 +85,23 @@ endif .PHONY: default default: all +.PHONY: test-pzstd +test-pzstd: TESTFLAGS='--gtest_filter=-*ExtremelyLarge*' +test-pzstd: clean googletest pzstd tests check + +.PHONY: test-pzstd32 +test-pzstd32: clean googletest32 all32 check + +.PHONY: test-pzstd-tsan +test-pzstd-tsan: LDFLAGS="-fuse-ld=gold" +test-pzstd-tsan: TESTFLAGS='--gtest_filter=-*ExtremelyLarge*' +test-pzstd-tsan: clean googletest tsan check + +.PHONY: test-pzstd-asan +test-pzstd-asan: LDFLAGS="-fuse-ld=gold" +test-pzstd-asan: TESTFLAGS='--gtest_filter=-*ExtremelyLarge*' +test-pzstd-asan: clean asan check + .PHONY: check check: $(TESTPROG) ./utils/test/BufferTest$(EXT) $(TESTFLAGS) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 58811191..a7b4fddc 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -399,7 +399,7 @@ int main(int argCount, const char* argv[]) while (argument[0]!=0) { if (lastCommand) { DISPLAY("error : command must be followed by argument \n"); - return 1; + CLEAN_RETURN(1); } #ifndef ZSTD_NOCOMPRESS /* compression Level */ @@ -555,7 +555,7 @@ int main(int argCount, const char* argv[]) filenameTable[filenameIdx++] = argument; } - if (lastCommand) { DISPLAY("error : command must be followed by argument \n"); return 1; } /* forgotten argument */ + if (lastCommand) { DISPLAY("error : command must be followed by argument \n"); CLEAN_RETURN(1); } /* forgotten argument */ /* Welcome message (if verbose) */ DISPLAYLEVEL(3, WELCOME_MESSAGE); diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index 9a9fed98..c22a284c 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c @@ -496,6 +496,8 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo /* Bug will cause checksum to fail */ if (ZSTD_isError(r)) goto _output_error; } + + ZSTD_freeDStream(zds); } DISPLAYLEVEL(3, "OK \n");