main.cpp: check log level range before using its value

(Silently) ignore invalid -l loglevel specs. This avoids a crash
reported in bug #1071.
This commit is contained in:
Gerhard Sittig 2018-01-02 22:13:06 +01:00 committed by Uwe Hermann
parent 83c59147c7
commit ed6f8680ba
1 changed files with 4 additions and 0 deletions

View File

@ -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