Plug some memory leaks.
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 2 Jul 2007 12:02:15 +0000 (15:02 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 2 Jul 2007 12:02:15 +0000 (15:02 +0300)
Patches from rpm5.org / JBJ.

lib/rpmal.c
lib/rpmrc.c
rpmio/macro.c

index db85c21..966afd0 100644 (file)
@@ -816,6 +816,7 @@ rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds, alKey * keyp)
        if (ret != NULL && *ret != NULL)
            return ret;
        /* ... then, look for files "provided" by package. */
+       ret = _free(ret);
     }
 
     ai = &al->index;
index b720fad..00afa9d 100644 (file)
@@ -1440,7 +1440,8 @@ static void rpmSetVarArch(int var, const char * val, const char * arch)
        }
     }
 
-    next->value = xstrdup(val);                /* XXX memory leak, hard to plug */
+    next->value = _free(next->value);
+    next->value = xstrdup(val);
     next->arch = (arch ? xstrdup(arch) : NULL);
 }
 
index 2cff4b1..e5b10e4 100644 (file)
@@ -1998,8 +1998,10 @@ rpmInitMacros(MacroContext mc, const char * macrofiles)
            continue;
 
        /* Read macros from each file. */
-       for (i = 0; i < ac; i++)
+       for (i = 0; i < ac; i++) {
            (void) rpmLoadMacroFile(mc, av[i]);
+           av[i] = _free(av[i]);
+       }
        av = _free(av);
     }
     mfiles = _free(mfiles);