From ed6f8680ba30649409b35ffccb7f815cb7b1a23a Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Tue, 2 Jan 2018 22:13:06 +0100 Subject: [PATCH] main.cpp: check log level range before using its value (Silently) ignore invalid -l loglevel specs. This avoids a crash reported in bug #1071. --- main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.cpp b/main.cpp index 8f495419..0f9aec2f 100644 --- a/main.cpp +++ b/main.cpp @@ -121,6 +121,10 @@ int main(int argc, char *argv[]) case 'l': { const int loglevel = atoi(optarg); + if (loglevel < 0 || loglevel > 5) { + qDebug() << "ERROR: invalid log level spec."; + break; + } context->set_log_level(sigrok::LogLevel::get(loglevel)); #ifdef ENABLE_DECODE -- 2.30.2