From 42249019f6ac3453c2244bc8aab343a86e48c4d2 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 14 Aug 2012 10:26:11 -0700 Subject: [PATCH] trim: Close some memory leaks. The parse_call() function allocates an object and returns a pointer, so we need to explicitly call delete on that object. --- cli/cli_trim.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/cli_trim.cpp b/cli/cli_trim.cpp index 69ff4e8..3fc3803 100644 --- a/cli/cli_trim.cpp +++ b/cli/cli_trim.cpp @@ -355,15 +355,20 @@ trim_trace(const char *filename, struct trim_options *options) /* There's no use doing any work past the last call requested * by the user. */ - if (call->no > options->calls.getLast()) + if (call->no > options->calls.getLast()) { + delete call; break; + } /* If requested, ignore all calls not belonging to the specified thread. */ - if (options->thread != -1 && call->thread_id != options->thread) + if (options->thread != -1 && call->thread_id != options->thread) { + delete call; continue; + } /* Also, prune if uninteresting (unless the user asked for no pruning. */ if (options->prune_uninteresting && call->flags & trace::CALL_FLAG_UNINTERESTING) { + delete call; continue; } @@ -381,6 +386,8 @@ trim_trace(const char *filename, struct trim_options *options) if (options->dependency_analysis) { analyzer.analyze(call); } + + delete call; } /* Prepare output file and writer for output. */ -- 2.43.0