From: Michael Wallner Date: Tue, 10 Nov 2020 15:18:18 +0000 (+0100) Subject: bin/memcat: fix leak X-Git-Tag: 1.1.0-beta1~115 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=40cdcf0d0e6828d8414e3367e356dfd78dcdd4fa;p=m6w6%2Flibmemcached bin/memcat: fix leak --- 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);