]> git.cworth.org Git - apitrace/commitdiff
trim: Close some memory leaks.
authorCarl Worth <cworth@cworth.org>
Tue, 14 Aug 2012 17:26:11 +0000 (10:26 -0700)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 22 Nov 2012 08:03:06 +0000 (08:03 +0000)
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

index 69ff4e8621136a4deb9175ae0c25144f0988fb2b..3fc3803cc4b2f5afeb13d84e7330105a2422fd35 100644 (file)
@@ -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. */