From: Carl Worth Date: Tue, 14 Aug 2012 17:26:11 +0000 (-0700) Subject: trim: Close some memory leaks. X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=42249019f6ac3453c2244bc8aab343a86e48c4d2;p=apitrace 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. --- 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. */