From d35eadb22c78b57d804c568bf6d5cf1643ff31d1 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Sun, 5 Jan 2025 13:46:30 +0200 Subject: [PATCH] preallocate capacity for yystack (by krishvishal) --- vendored/sqlite3-parser/third_party/lemon/lemon.c | 2 ++ vendored/sqlite3-parser/third_party/lemon/lempar.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vendored/sqlite3-parser/third_party/lemon/lemon.c b/vendored/sqlite3-parser/third_party/lemon/lemon.c index d81d8e8a7..dec7efd25 100644 --- a/vendored/sqlite3-parser/third_party/lemon/lemon.c +++ b/vendored/sqlite3-parser/third_party/lemon/lemon.c @@ -4518,6 +4518,8 @@ void ReportTable( print_stack_union(out,lemp,&lineno); if( lemp->stacksize ){ fprintf(out,"const YYSTACKDEPTH: usize = %s;\n",lemp->stacksize); lineno++; + } else { + fprintf(out, "const YYSTACKDEPTH: usize = 128;\n"); lineno++; } if( lemp->errsym && lemp->errsym->useCnt ){ fprintf(out,"const YYERRORSYMBOL: YYCODETYPE = %d;\n",lemp->errsym->index); lineno++; diff --git a/vendored/sqlite3-parser/third_party/lemon/lempar.rs b/vendored/sqlite3-parser/third_party/lemon/lempar.rs index 8a0bef7cf..4bee616f4 100644 --- a/vendored/sqlite3-parser/third_party/lemon/lempar.rs +++ b/vendored/sqlite3-parser/third_party/lemon/lempar.rs @@ -285,7 +285,7 @@ impl yyParser<'_> { yyidx: 0, #[cfg(feature = "YYTRACKMAXSTACKDEPTH")] yyhwm: 0, - yystack: Vec::new(), + yystack: Vec::with_capacity(YYSTACKDEPTH), //#[cfg(not(feature = "YYNOERRORRECOVERY"))] yyerrcnt: -1, %% /* Optional %extra_context store */