From: Michael Tremer Date: Sat, 11 Jan 2025 14:21:37 +0000 (+0000) Subject: parser: Slightly improve expanding variables X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b77626c87825d2b7fdccbdd6680a5a267a49b7b;p=people%2Fric9%2Fpakfire.git parser: Slightly improve expanding variables Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/parser.c b/src/pakfire/parser.c index 90302d768..737ad3743 100644 --- a/src/pakfire/parser.c +++ b/src/pakfire/parser.c @@ -668,22 +668,25 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser, #endif /* PAKFIRE_DEBUG_PARSER */ // Replace all occurrences - char* tmp = pakfire_string_replace(*buffer, (const char*)pattern, (repl) ? repl : ""); - if (!tmp) + char* tmp = pakfire_string_replace(*buffer, (const char*)pattern, repl); + if (!tmp) { + r = -errno; goto ERROR; + } // Replace buffer free(*buffer); *buffer = tmp; // Free resources - if (variable) + if (variable) { pcre2_substring_free(variable); - variable = NULL; - - if (pattern) + variable = NULL; + } + if (pattern) { pcre2_substring_free(pattern); - pattern = NULL; + pattern = NULL; + } } ERROR: