hhctrl.ocx: Fix the mem handling in get_attr() (Smatch).

Michael Stefaniuc mstefani at redhat.de
Tue Jan 26 15:13:54 CST 2010


name_buf is allocated on the stack and node_buf by heap_alloc.
Also don't leak node_buf when leaving the function.
---
 dlls/hhctrl.ocx/content.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/dlls/hhctrl.ocx/content.c b/dlls/hhctrl.ocx/content.c
index 39be04b..10de54c 100644
--- a/dlls/hhctrl.ocx/content.c
+++ b/dlls/hhctrl.ocx/content.c
@@ -186,7 +186,7 @@ static const char *get_attr(const char *node, const char *name, int *len)
     ptr = strstr(node_buf, name_buf);
     if(!ptr) {
         WARN("name not found\n");
-        heap_free(name_buf);
+        heap_free(node_buf);
         return NULL;
     }
 
@@ -194,14 +194,16 @@ static const char *get_attr(const char *node, const char *name, int *len)
     ptr2 = strchr(ptr, '\"');
     if(!ptr2)
     {
-        heap_free(name_buf);
+        heap_free(node_buf);
         return NULL;
     }
 
     *len = ptr2-ptr;
-    heap_free(name_buf);
     /* Return the pointer offset within the original string */
-    return node+(ptr-node_buf);
+    ptr = node+(ptr-node_buf);
+
+    heap_free(node_buf);
+    return ptr;
 }
 
 static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text)
-- 
1.6.6



More information about the wine-patches mailing list