moc: fix infinite loop over malformed input
We should not call prev() if we had already reched the end. Task-number: QTBUG-54815 Change-Id: I56bc86880a0dbfdce57fc4a08e5950f2ff3a5958 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
parent
af6f7179e8
commit
af055964f5
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the tools applications of the Qt Toolkit.
|
||||
@ -184,6 +185,8 @@ Type Moc::parseType()
|
||||
case Q_SLOT_TOKEN:
|
||||
type.name += lexem();
|
||||
return type;
|
||||
case NOTOKEN:
|
||||
return type;
|
||||
default:
|
||||
prev();
|
||||
break;
|
||||
@ -218,6 +221,8 @@ Type Moc::parseType()
|
||||
type.name += lexem();
|
||||
isVoid |= (lookup(0) == VOID);
|
||||
break;
|
||||
case NOTOKEN:
|
||||
return type;
|
||||
default:
|
||||
prev();
|
||||
;
|
||||
|
@ -1942,6 +1942,13 @@ void tst_Moc::warnings_data()
|
||||
<< 1
|
||||
<< QString("IGNORE_ALL_STDOUT")
|
||||
<< QString(":-1: Error: Unexpected character in macro argument list.");
|
||||
|
||||
QTest::newRow("QTBUG-54815: Crash on invalid input")
|
||||
<< QByteArray("class M{(})F<{}d000000000000000#0")
|
||||
<< QStringList()
|
||||
<< 0
|
||||
<< QString()
|
||||
<< QString("standard input:1: Note: No relevant classes found. No output generated.");
|
||||
}
|
||||
|
||||
void tst_Moc::warnings()
|
||||
|
Loading…
Reference in New Issue
Block a user