File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 31
31
// don't redeclare malloc/free
32
32
#define YYINCLUDED_STDLIB_H 1
33
33
34
+ // maximum number of errors encountered before parser aborts
35
+ #define MAX_ERRORS 10
36
+
34
37
struct expression_parser_context ;
35
38
#include " qgsexpressionparser.hpp"
36
39
@@ -177,7 +180,10 @@ root: expression { parser_ctx->rootNode = $1; }
177
180
| error expression
178
181
{
179
182
delete $2 ;
180
- yyerrok ;
183
+ if ( parser_ctx->parserErrors.count() < MAX_ERRORS )
184
+ yyerrok ;
185
+ else
186
+ YYABORT ;
181
187
}
182
188
;
183
189
Original file line number Diff line number Diff line change @@ -287,6 +287,14 @@ class TestQgsExpression: public QObject
287
287
QCOMPARE ( exp.parserErrors ().first ().lastColumn , lastColumn );
288
288
}
289
289
290
+ void max_errors ()
291
+ {
292
+ QgsExpression e ( " wkt_geom	OBJECTID	id	a	b	c	d	e	f	g	h	i	j	k	l	m	n	o	p	q	r	" );
293
+ QVERIFY ( e.hasParserError () );
294
+ // want parsing to abort after a maximum of 10 errors
295
+ QCOMPARE ( e.parserErrors ().count (), 10 );
296
+ }
297
+
290
298
void parsing_with_locale ()
291
299
{
292
300
// check that parsing of numbers works correctly even when using some other locale
You can’t perform that action at this time.
0 commit comments