[PATCH] webservices: Fixed memory leaks in one error condition (Coverity)

Marcus Meissner marcus at jet.franken.de
Sun Mar 6 06:40:07 CST 2016


1355268 Resource leak
	localname is not freed in error exit node
1355269 Resource leak
	prefix is not used anymore / freed in the true if branch

Signed-off-by: Marcus Meissner <marcus at jet.franken.de>
---
 dlls/webservices/reader.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 72e75c3..688bc2b 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -928,7 +928,7 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
     WS_XML_UTF8_TEXT *text;
     unsigned int len = 0, ch, skip, quote;
     const unsigned char *start;
-    WS_XML_STRING *prefix, *localname;
+    WS_XML_STRING *prefix, *localname = NULL;
     HRESULT hr = WS_E_INVALID_FORMAT;
 
     if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
@@ -948,7 +948,11 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
     if (WsXmlStringEquals( prefix, &xmlns, NULL ) == S_OK)
     {
         attr->isXmlNs   = 1;
-        if (!(attr->prefix = alloc_xml_string( localname->bytes, localname->length ))) goto error;
+	heap_free (prefix);
+        if (!(attr->prefix = alloc_xml_string( localname->bytes, localname->length ))) {
+		heap_free (localname);
+		goto error;
+	}
         attr->localName = localname;
     }
     else
-- 
2.7.2




More information about the wine-patches mailing list