From: Aki Tuomi Date: Mon, 15 Dec 2025 09:52:18 +0000 (+0200) Subject: lib-var-expand: Check that there is program before switching it as previous program X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d73129f92631276661c84ce3794b38cd7a70570;p=thirdparty%2Fdovecot%2Fcore.git lib-var-expand: Check that there is program before switching it as previous program --- diff --git a/src/lib-var-expand/test-var-expand.c b/src/lib-var-expand/test-var-expand.c index 2a4db34944..4af0a9395b 100644 --- a/src/lib-var-expand/test-var-expand.c +++ b/src/lib-var-expand/test-var-expand.c @@ -648,6 +648,7 @@ static void test_var_expand_escape(void) { .in = "no variables", .out = "no variables", .ret = 0 }, { .in = "%{literal('hello')}", .out = "'hello'", .ret = 0 }, { .in = "hello\\tworld", .out = "hello\\tworld", .ret = 0 }, + { .in = "%%%%%%%%%%%%%%%%%%", .out = "%%%%%%%%%%%%%%%%%%", .ret = 0 }, { .in = "%{literal('hello\r\n\tworld')}", .out = "'hello\r\n\tworld'", .ret = 0 }, /* Hello */ { .in = "\\110\\145\\154\\154\\157", .out = "\\110\\145\\154\\154\\157", .ret = 0}, diff --git a/src/lib-var-expand/var-expand-parser.y b/src/lib-var-expand/var-expand-parser.y index 8a83179e88..d06e469763 100644 --- a/src/lib-var-expand/var-expand-parser.y +++ b/src/lib-var-expand/var-expand-parser.y @@ -241,8 +241,10 @@ static void push_function(VAR_EXPAND_PARSER_STYPE *state, const char *func) static void push_new_program(VAR_EXPAND_PARSER_STYPE *pstate) { - pstate->pp = pstate->p; - pstate->p = NULL; + if (pstate->p != NULL) { + pstate->pp = pstate->p; + pstate->p = NULL; + } } /* Special optimization: If the previous program was also a literal, reuse it