From be7eede9c5abc22ec53cc02bef6e61ca53d0de25 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Sun, 15 Nov 2026 12:48:20 +0530 Subject: [PATCH] samples: add error check for invalid frame count in application_trace (#30801) * samples: add error check for invalid frame count in application_trace * samples: reject only negative frame counts * samples: clarify frame count messages in application_trace --- samples/cpp/application_trace.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/samples/cpp/application_trace.cpp b/samples/cpp/application_trace.cpp index 3ad06a4ccd..52cf79fa1b 100644 --- a/samples/cpp/application_trace.cpp +++ b/samples/cpp/application_trace.cpp @@ -28,7 +28,7 @@ int main(int argc, char** argv) cv::CommandLineParser parser(argc, argv, "{help h ? | | help message}" - "{n | 100 | number of frames to process }" + "{n | 100 | number of frames to process (0 for unlimited) }" "{@video | 0 | video filename or cameraID }" ); if (parser.has("help")) @@ -59,6 +59,11 @@ int main(int argc, char** argv) } int N = parser.get("n"); + if (N < 0) + { + cerr << "Error: Number of frames to process must be a non-negative integer." << endl; + return -1; + } if (nframes > 0 && N > nframes) N = nframes;