From 7d1ba6b066cee563e1b52f712146bd2b322ef2ef Mon Sep 17 00:00:00 2001 From: Christian Menges Date: Sun, 9 May 2021 12:12:01 +0200 Subject: Fix memory leaks in examples (#604) --- example/passthrough_hp.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'example/passthrough_hp.cc') diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc index 3e11266..e976166 100644 --- a/example/passthrough_hp.cc +++ b/example/passthrough_hp.cc @@ -1126,7 +1126,11 @@ static cxxopts::ParseResult parse_options(int argc, char **argv) { fs.debug = options.count("debug") != 0; fs.nosplice = options.count("nosplice") != 0; - fs.source = std::string {realpath(argv[1], NULL)}; + char* resolved_path = realpath(argv[1], NULL); + if (resolved_path == NULL) + warn("WARNING: realpath() failed with"); + fs.source = std::string {resolved_path}; + free(resolved_path); return options; } -- cgit v1.2.3