]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Fix small memory leak in names-cache
authorMartin Mares <mj@ucw.cz>
Fri, 12 Dec 2014 17:18:35 +0000 (18:18 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 12 Dec 2014 17:18:35 +0000 (18:18 +0100)
Signed-off-by: Tomáš Chvátal <tchvatal@suse.cz>
---
 lib/names-cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/names-cache.c b/lib/names-cache.c
index 90a6454..c97ea30 100644
--- a/lib/names-cache.c
+++ b/lib/names-cache.c
@@ -39,7 +39,8 @@ static char *get_cache_name(struct pci_access *a)
   buf = pci_malloc(a, strlen(pw->pw_dir) + strlen(name+1) + 1);
   sprintf(buf, "%s%s", pw->pw_dir, name+1);
   pci_set_param_internal(a, "net.cache_name", buf, 0);
-  return buf;
+  pci_mfree(buf);
+  return pci_get_param(a, "net.cache_name");
 }

 int
--
2.1.3

lib/names-cache.c

index 90a6454a2c91781d9b331b82e165a0e5d9bc00b3..c97ea302ebe9cb6649d4834c1ad34695c3b0ed07 100644 (file)
@@ -39,7 +39,8 @@ static char *get_cache_name(struct pci_access *a)
   buf = pci_malloc(a, strlen(pw->pw_dir) + strlen(name+1) + 1);
   sprintf(buf, "%s%s", pw->pw_dir, name+1);
   pci_set_param_internal(a, "net.cache_name", buf, 0);
-  return buf;
+  pci_mfree(buf);
+  return pci_get_param(a, "net.cache_name");
 }
 
 int