File pciutils-3.1.7-fix-memory-leak-in-get_cache_name.patch of Package pciutils.3737

From 613ddbcab727130f23035e69da1f97a17f9cdba3 Mon Sep 17 00:00:00 2001
From: Michal Vyskocil <mvyskocil@suse.com>
Date: Thu, 26 Sep 2013 11:45:20 +0200
Subject: [PATCH] fix memory leak in get_cache_name

Function get_cache_name does allocate buffer and add it to struct pci_access
via pci_set_param_internal with copy=0. In this mode the pointer is
simply added to linked list, but marked with value_mallocated 0,
therefor newer free'ed.

Fixes: https://bugzilla.novell.com/show_bug.cgi?id=837347
---
 lib/names-cache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/names-cache.c b/lib/names-cache.c
index 90a6454..89e67e6 100644
--- a/lib/names-cache.c
+++ b/lib/names-cache.c
@@ -38,8 +38,9 @@ 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_set_param(a, "net.cache_name", buf);
+  pci_mfree(buf);
+  return pci_get_param(a, "net.cache_name");
 }
 
 int
-- 
1.8.4

openSUSE Build Service is sponsored by