From 40cdcf0d0e6828d8414e3367e356dfd78dcdd4fa Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 10 Nov 2020 16:18:18 +0100 Subject: [PATCH] bin/memcat: fix leak --- src/bin/memcat.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/memcat.cc b/src/bin/memcat.cc index 50e21395..ca69d6f9 100644 --- a/src/bin/memcat.cc +++ b/src/bin/memcat.cc @@ -133,7 +133,6 @@ int main(int argc, char *argv[]) { std::cout.write(string, string_length); std::cout << std::endl; } - free(string); } } else if (rc != MEMCACHED_NOTFOUND) { std::cerr << "error on " << argv[optind] << "(" << memcached_strerror(memc, rc) << ")"; @@ -152,6 +151,11 @@ int main(int argc, char *argv[]) { return_code = EXIT_FAILURE; } optind++; + free(string); + string = nullptr; + } + if (string) { + free(string); } memcached_free(memc); -- 2.30.2