From 2b77626c87825d2b7fdccbdd6680a5a267a49b7b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 11 Jan 2025 14:21:37 +0000 Subject: [PATCH] parser: Slightly improve expanding variables Signed-off-by: Michael Tremer --- src/pakfire/parser.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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: -- 2.47.3