]> git.cworth.org Git - apitrace/blobdiff - cli/cli_trim.cpp
trim: Fix early-bailout bug when accepting both --calls and --frames
[apitrace] / cli / cli_trim.cpp
index b0cb8f167557fbe162b174a50ddf2610ce905b2b..13436705dbe71aebe982e34b4b818311255c7e20 100644 (file)
@@ -196,11 +196,11 @@ trim_trace(const char *filename, struct trim_options *options)
     trace::Call *call;
     while ((call = p.parse_call())) {
 
-        /* There's no use doing any work past the last call or frame
+        /* There's no use doing any work past the last call and frame
          * requested by the user. */
-        if (call->no > options->calls.getLast() ||
-            frame > options->frames.getLast()) {
-            
+        if ((options->calls.empty() || call->no > options->calls.getLast()) &&
+            (options->frames.empty() || frame > options->frames.getLast())) {
+
             delete call;
             break;
         }
@@ -264,10 +264,10 @@ trim_trace(const char *filename, struct trim_options *options)
     call_range_last = -1;
     while ((call = p.parse_call())) {
 
-        /* There's no use doing any work past the last call or frame
+        /* There's no use doing any work past the last call and frame
          * requested by the user. */
-        if (call->no > options->calls.getLast() ||
-            frame > options->frames.getLast()) {
+        if ((options->calls.empty() || call->no > options->calls.getLast()) &&
+            (options->frames.empty() || frame > options->frames.getLast())) {
 
             break;
         }