Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
2d9da518
Commit
2d9da518
authored
Sep 16, 2009
by
Roberto Raggi
Browse files
Fixed possible crash in the QtScript parser.
parent
9fc41bc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/qtscripteditor/parser/javascript.g
View file @
2d9da518
...
...
@@ -428,7 +428,7 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver)
_Lcheck_token:
if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
yyprevlloc = yylloc;
yyprevlloc = yylloc;
if (first_token == last_token) {
yytoken = lexer->lex();
...
...
@@ -2119,7 +2119,12 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
token_buffer[1].loc = yylloc = location(lexer);
if (t_action(errorState, yytoken)) {
const QString msg = QString::fromUtf8("Removed token: `%1'").arg(spell[token_buffer[0].token]);
QString msg = QString::fromUtf8("Removed token");
if (const char *tokenSpell = spell[token_buffer[0].token]) {
msg += QLatin1String(": `");
msg += QLatin1String(tokenSpell);
msg += QLatin1Char('\'');
}
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
...
...
@@ -2149,7 +2154,12 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
int a = t_action(errorState, *tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = QString::fromUtf8("Inserted token: `%1'").arg(spell[*tk]);
QString msg = QString::fromUtf8("Inserted token");
if (const char *tokenSpell = spell[*tk]) {
msg += QLatin1String(": `");
msg += QLatin1String(tokenSpell);
msg += QLatin1Char('\'');
}
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
...
...
@@ -2169,7 +2179,13 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
int a = t_action(errorState, tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = QString::fromUtf8("Inserted token: `%1'").arg(spell[tk]);
QString msg = QString::fromUtf8("Inserted token");
if (const char *tokenSpell = spell[tk]) {
msg += QLatin1String(": `");
msg += QLatin1String(tokenSpell);
msg += QLatin1Char('\'');
}
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
...
...
@@ -2182,7 +2198,13 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
}
}
const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(spell[token_buffer[0].token]);
QString msg = QString::fromUtf8("Unexpected token");
if (const char *tokenSpell = spell[token_buffer[0].token]) {
msg += QLatin1String(": `");
msg += QLatin1String(tokenSpell);
msg += QLatin1Char('\'');
}
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
}
...
...
src/plugins/qtscripteditor/parser/javascriptgrammar.cpp
View file @
2d9da518
// This file was generated by qlalr - DO NOT EDIT!
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include
"javascriptgrammar_p.h"
const
char
*
const
JavaScriptGrammar
::
spell
[]
=
{
...
...
src/plugins/qtscripteditor/parser/javascriptparser.cpp
View file @
2d9da518
...
...
@@ -132,7 +132,7 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver)
_Lcheck_token:
if
(
yytoken
==
-
1
&&
-
TERMINAL_COUNT
!=
action_index
[
action
])
{
yyprevlloc
=
yylloc
;
yyprevlloc
=
yylloc
;
if
(
first_token
==
last_token
)
{
yytoken
=
lexer
->
lex
();
...
...
@@ -1123,7 +1123,12 @@ case 266: {
token_buffer
[
1
].
loc
=
yylloc
=
location
(
lexer
);
if
(
t_action
(
errorState
,
yytoken
))
{
const
QString
msg
=
QString
::
fromUtf8
(
"Removed token: `%1'"
).
arg
(
spell
[
token_buffer
[
0
].
token
]);
QString
msg
=
QString
::
fromUtf8
(
"Removed token"
);
if
(
const
char
*
tokenSpell
=
spell
[
token_buffer
[
0
].
token
])
{
msg
+=
QLatin1String
(
": `"
);
msg
+=
QLatin1String
(
tokenSpell
);
msg
+=
QLatin1Char
(
'\''
);
}
diagnostic_messages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
token_buffer
[
0
].
loc
.
startLine
,
token_buffer
[
0
].
loc
.
startColumn
,
msg
));
...
...
@@ -1153,7 +1158,12 @@ case 266: {
for
(
int
*
tk
=
tokens
;
*
tk
!=
EOF_SYMBOL
;
++
tk
)
{
int
a
=
t_action
(
errorState
,
*
tk
);
if
(
a
>
0
&&
t_action
(
a
,
yytoken
))
{
const
QString
msg
=
QString
::
fromUtf8
(
"Inserted token: `%1'"
).
arg
(
spell
[
*
tk
]);
QString
msg
=
QString
::
fromUtf8
(
"Inserted token"
);
if
(
const
char
*
tokenSpell
=
spell
[
*
tk
])
{
msg
+=
QLatin1String
(
": `"
);
msg
+=
QLatin1String
(
tokenSpell
);
msg
+=
QLatin1Char
(
'\''
);
}
diagnostic_messages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
token_buffer
[
0
].
loc
.
startLine
,
token_buffer
[
0
].
loc
.
startColumn
,
msg
));
...
...
@@ -1173,7 +1183,13 @@ case 266: {
for
(
int
tk
=
1
;
tk
<
TERMINAL_COUNT
;
++
tk
)
{
int
a
=
t_action
(
errorState
,
tk
);
if
(
a
>
0
&&
t_action
(
a
,
yytoken
))
{
const
QString
msg
=
QString
::
fromUtf8
(
"Inserted token: `%1'"
).
arg
(
spell
[
tk
]);
QString
msg
=
QString
::
fromUtf8
(
"Inserted token"
);
if
(
const
char
*
tokenSpell
=
spell
[
tk
])
{
msg
+=
QLatin1String
(
": `"
);
msg
+=
QLatin1String
(
tokenSpell
);
msg
+=
QLatin1Char
(
'\''
);
}
diagnostic_messages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
token_buffer
[
0
].
loc
.
startLine
,
token_buffer
[
0
].
loc
.
startColumn
,
msg
));
...
...
@@ -1186,7 +1202,13 @@ case 266: {
}
}
const
QString
msg
=
QString
::
fromUtf8
(
"Unexpected token: `%1'"
).
arg
(
spell
[
token_buffer
[
0
].
token
]);
QString
msg
=
QString
::
fromUtf8
(
"Unexpected token"
);
if
(
const
char
*
tokenSpell
=
spell
[
token_buffer
[
0
].
token
])
{
msg
+=
QLatin1String
(
": `"
);
msg
+=
QLatin1String
(
tokenSpell
);
msg
+=
QLatin1Char
(
'\''
);
}
diagnostic_messages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
token_buffer
[
0
].
loc
.
startLine
,
token_buffer
[
0
].
loc
.
startColumn
,
msg
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment