]> sigrok.org Git - pulseview.git/commitdiff
main.cpp: check log level range before using its value
authorGerhard Sittig <redacted>
Tue, 2 Jan 2018 21:13:06 +0000 (22:13 +0100)
committerUwe Hermann <redacted>
Wed, 10 Jan 2018 18:19:35 +0000 (19:19 +0100)
(Silently) ignore invalid -l loglevel specs. This avoids a crash
reported in bug #1071.

main.cpp

index 8f495419fee7467de77c4074c32927ce658de919..0f9aec2f7adc6316a1dd05d26b3417b12df454df 100644 (file)
--- 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