]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: Check that there is program before switching it as previous program
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 15 Dec 2025 09:52:18 +0000 (11:52 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 15 Dec 2025 10:26:26 +0000 (12:26 +0200)
src/lib-var-expand/test-var-expand.c
src/lib-var-expand/var-expand-parser.y

index 2a4db349445fbe8146a58bc522d35e88b7b68f42..4af0a9395bbbc11dca82eea171dd35337fedf364 100644 (file)
@@ -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},
index 8a83179e88da9524cbbc66cdf7ae5dfa5edab199..d06e469763b9a91ca87b07a336b3e79d96ff0a32 100644 (file)
@@ -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