From f3660c25e136966b3113f252f4900bca87f6ed3a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 15 Jan 2013 13:30:55 +0100 Subject: Make numeric-literal parsing even more robust. The numeric value could overflow a unsigned 64-bit integer, so instead just buffer the string and have libc's strtod handle all the conversion. Change-Id: I220e490ddc22363460b0df65a91b47336e747310 Reviewed-by: Simon Hausmann --- src/qml/qml/parser/qqmljslexer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp index b2020d86a4..d154cec0c6 100644 --- a/src/qml/qml/parser/qqmljslexer.cpp +++ b/src/qml/qml/parser/qqmljslexer.cpp @@ -889,12 +889,14 @@ again: int Lexer::scanNumber(QChar ch) { if (ch != QLatin1Char('0')) { - quint64 integer = ch.unicode() - '0'; + QByteArray buf; + buf.reserve(64); + buf += ch.toLatin1(); QChar n = _char; const QChar *code = _codePtr; while (n.isDigit()) { - integer = integer * 10 + (n.unicode() - '0'); + buf += n.toLatin1(); n = *code++; } @@ -903,7 +905,8 @@ int Lexer::scanNumber(QChar ch) _codePtr = code - 1; scanChar(); } - _tokenValue = integer; + buf.append('\0'); + _tokenValue = strtod(buf.constData(), 0); return T_NUMERIC_LITERAL; } } else if (_char.isDigit() && !qmlMode()) { -- cgit v1.2.3