Commit 4f07e4f0 authored by Sven Baars's avatar Sven Baars Committed by Alexandre Julliard

webservices: Fix some leaks on error paths (Coverity).

parent 43eb22c5
...@@ -1552,12 +1552,12 @@ HRESULT WINAPI WsRemoveMappedHeader( WS_MESSAGE *handle, const WS_XML_STRING *na ...@@ -1552,12 +1552,12 @@ HRESULT WINAPI WsRemoveMappedHeader( WS_MESSAGE *handle, const WS_XML_STRING *na
return hr; 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 ); *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; 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 ); MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, *ret, *len );
(*ret)[len] = 0; (*ret)[*len] = 0;
return S_OK; return S_OK;
} }
...@@ -1565,9 +1565,10 @@ static HRESULT get_header_value_wsz( struct header *header, WS_READ_OPTION optio ...@@ -1565,9 +1565,10 @@ static HRESULT get_header_value_wsz( struct header *header, WS_READ_OPTION optio
ULONG size ) ULONG size )
{ {
WCHAR *str = NULL; WCHAR *str = NULL;
int len = 0;
HRESULT hr; 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) switch (option)
{ {
...@@ -1577,12 +1578,17 @@ static HRESULT get_header_value_wsz( struct header *header, WS_READ_OPTION optio ...@@ -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_OPTIONAL_POINTER:
case WS_READ_NILLABLE_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; *ret = str;
break; break;
default: default:
FIXME( "read option %u not supported\n", option ); FIXME( "read option %u not supported\n", option );
ws_free( heap, str, (len + 1) * sizeof(WCHAR) );
return E_NOTIMPL; return E_NOTIMPL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment