commit:     60b48bf693d25a5a7b09199f9756310b5d7209bf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  7 08:31:42 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Feb  7 08:31:42 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=60b48bf6

main: workaround hypothetical resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 884d6da..b22d6f4 100644
--- a/main.c
+++ b/main.c
@@ -584,12 +584,12 @@ read_portage_file(const char *file, enum 
portage_file_type type, void *data)
                                void *e;
                                snprintf(npath, sizeof(npath), "%s:%zu:%zu-%zu",
                                                file, line, cbeg, cend);
-                               p = xstrdup(npath);
                                /* if not necessary, but do it for static code 
analysers
                                 * which take into accound that add_set_value 
might
                                 * allocate a new set when masks would be NULL 
-- a case
                                 * which would never happen */
                                if (masks != NULL) {
+                                       p = xstrdup(npath);
                                        add_set_value(buf, p, &e, masks);
                                        if (e != NULL)
                                                free(p);

Reply via email to