commit:     cc013611ef364a970f829df3c4ea7c919f2333dc
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 04:31:01 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 04:31:01 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cc013611

fix minor overlay memory leak w/repos.conf parsing

When repos.conf is active, we end up leaking the default main overlay
memory.  Make sure we free it if repos.conf was loaded.

Also drop the old closing of stderr so asan can write its output.  The
addition of this call was due to a bug in the old stderr reopen logic
that was rewritten in commit ba5f0328.

 main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 208f899..be25d08 100644
--- a/main.c
+++ b/main.c
@@ -905,7 +905,10 @@ void initialize_portage_env(void)
                portroot[var->value_len + 1] = '\0';
        }
 
+       char *orig_main_overlay = main_overlay;
        read_repos_conf(configroot, CONFIG_EPREFIX "etc/portage/repos.conf");
+       if (orig_main_overlay != main_overlay)
+               free(orig_main_overlay);
        if (array_cnt(overlays) == 0)
                xarraypush_str(overlays, main_overlay);
 
@@ -1380,7 +1383,6 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 void cleanup(void)
 {
        reinitialize_as_needed();
-       fclose(stderr);
 }
 
 int main(int argc, char **argv)

Reply via email to