Plug minor memleak from default rc and macro file paths
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 27 Mar 2009 11:45:08 +0000 (13:45 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 3 Apr 2009 11:38:47 +0000 (14:38 +0300)
- build code can call these several times, only init once
(cherry picked from commit a5eeff6d42d6452a85942f89a6b3a1196ccc47bc)

lib/rpmrc.c

index 5909cc7..cf0cd1f 100644 (file)
@@ -451,19 +451,23 @@ export RPM_BUILD_ROOT\n}\
 static void setDefaults(void)
 {
     const char *confdir = rpmConfigDir();
-    defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":",
+    if (!defrcfiles) {
+       defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":",
                                confdir, "/" RPMCANONVENDOR "/rpmrc", ":",
                                SYSCONFDIR "/rpmrc", ":",
                                "~/.rpmrc", NULL);
+    }
 
 #ifndef MACROFILES
-    macrofiles = rstrscat(NULL, confdir, "/macros", ":",
+    if (!macrofiles) {
+       macrofiles = rstrscat(NULL, confdir, "/macros", ":",
                                confdir, "/platform/%{_target}/macros", ":",
                                confdir, "/" RPMCANONVENDOR "/macros", ":",
                                SYSCONFDIR "/rpm/macros.*", ":",
                                SYSCONFDIR "/rpm/macros", ":",
                                SYSCONFDIR "/rpm/%{_target}/macros", ":",
                                "~/.rpmmacros", NULL);
+    }
 #else
     macrofiles = MACROFILES;
 #endif