]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
parser: Stop expanding variables if the string becomes empty
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 14:35:14 +0000 (14:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 14:35:14 +0000 (14:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/parser.c

index 0614cd73e973253a8d28d9c82239979fb29482e1..0433e63d44162ab01627c6b7b8a759034896efa2 100644 (file)
@@ -511,7 +511,7 @@ static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char**
                "/bin/sh", "-c", NULL /* will be replaced by command later */, NULL,
        };
 
-       for (;;) {
+       while (buffer && *buffer) {
                // Perform matching
                r = pcre2_jit_match(regexes.command,
                        (PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL);
@@ -621,7 +621,7 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser,
        match = pcre2_match_data_create_from_pattern(regexes.variable, NULL);
 
        // Search for any variables
-       for (;;) {
+       while (buffer && *buffer) {
                // Perform matching
                r = pcre2_jit_match(regexes.variable,
                        (PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL);