[PATCH 5/5] sparcPromPathname2Node: free name when returning error, instead of leaking it

Alan Coopersmith alan.coopersmith at oracle.com
Sun Feb 10 12:39:36 PST 2013


Reported with other leaks found by cppcheck in bugzilla #50281
https://bugs.freedesktop.org/show_bug.cgi?id=50281

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/xfree86/os-support/bus/Sbus.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c
index 8260007..14e6d4b 100644
--- a/hw/xfree86/os-support/bus/Sbus.c
+++ b/hw/xfree86/os-support/bus/Sbus.c
@@ -617,8 +617,10 @@ sparcPromPathname2Node(const char *pathName)
         return 0;
     strcpy(name, pathName);
     name[i + 1] = 0;
-    if (name[0] != '/')
+    if (name[0] != '/') {
+        free(name);
         return 0;
+    }
     p = strchr(name + 1, '/');
     if (p)
         *p = 0;
@@ -629,8 +631,10 @@ sparcPromPathname2Node(const char *pathName)
         *regstr++ = 0;
     else
         regstr = p;
-    if (name + 1 == regstr)
+    if (name + 1 == regstr) {
+        free(name);
         return 0;
+    }
     promGetSibling(0);
     i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0);
     free(name);
-- 
1.7.9.2



More information about the xorg-devel mailing list