Sven Baars : webservices: Fix some leaks on error paths (Coverity).
Alexandre Julliard
julliard at winehq.org
Mon Oct 21 15:28:38 CDT 2019
Module: wine
Branch: master
Commit: 4f07e4f014587d016ea159c16052d30f0ea72a43
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4f07e4f014587d016ea159c16052d30f0ea72a43
Author: Sven Baars <sven.wine at gmail.com>
Date: Mon Oct 21 11:22:06 2019 +0200
webservices: Fix some leaks on error paths (Coverity).
Signed-off-by: Sven Baars <sven.wine at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/webservices/msg.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c
index a006841be6..6922224a05 100644
--- a/dlls/webservices/msg.c
+++ b/dlls/webservices/msg.c
@@ -1552,12 +1552,12 @@ HRESULT WINAPI WsRemoveMappedHeader( WS_MESSAGE *handle, const WS_XML_STRING *na
return hr;
}
-static HRESULT xmlstring_to_wsz( const WS_XML_STRING *str, WS_HEAP *heap, WCHAR **ret )
+static HRESULT xmlstring_to_wsz( const WS_XML_STRING *str, WS_HEAP *heap, WCHAR **ret, int *len )
{
- int len = MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, NULL, 0 );
- if (!(*ret = ws_alloc( heap, (len + 1) * sizeof(WCHAR) ))) return WS_E_QUOTA_EXCEEDED;
- MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, *ret, len );
- (*ret)[len] = 0;
+ *len = MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, NULL, 0 );
+ if (!(*ret = ws_alloc( heap, (*len + 1) * sizeof(WCHAR) ))) return WS_E_QUOTA_EXCEEDED;
+ MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, *ret, *len );
+ (*ret)[*len] = 0;
return S_OK;
}
@@ -1565,9 +1565,10 @@ static HRESULT get_header_value_wsz( struct header *header, WS_READ_OPTION optio
ULONG size )
{
WCHAR *str = NULL;
+ int len = 0;
HRESULT hr;
- if (header && (hr = xmlstring_to_wsz( header->u.text, heap, &str )) != S_OK) return hr;
+ if (header && (hr = xmlstring_to_wsz( header->u.text, heap, &str, &len )) != S_OK) return hr;
switch (option)
{
@@ -1577,12 +1578,17 @@ static HRESULT get_header_value_wsz( struct header *header, WS_READ_OPTION optio
case WS_READ_OPTIONAL_POINTER:
case WS_READ_NILLABLE_POINTER:
- if (size != sizeof(str)) return E_INVALIDARG;
+ if (size != sizeof(str))
+ {
+ ws_free( heap, str, (len + 1) * sizeof(WCHAR) );
+ return E_INVALIDARG;
+ }
*ret = str;
break;
default:
FIXME( "read option %u not supported\n", option );
+ ws_free( heap, str, (len + 1) * sizeof(WCHAR) );
return E_NOTIMPL;
}
More information about the wine-cvs
mailing list