[PATCH] webservices: free the potentially allocated pointer (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sat Dec 17 05:48:33 CST 2016
1374356 Resource leak
Signed-off-by: Marcus Meissner <marcus at jet.franken.de>
---
dlls/webservices/reader.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index d67c47a701..219683b2af 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -4701,15 +4701,33 @@ static ULONG get_field_size( const WS_FIELD_DESCRIPTION *desc )
static HRESULT read_param( struct reader *reader, const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap, void *ret )
{
- if (!ret && !(ret = ws_alloc_zero( heap, get_field_size(desc) ))) return WS_E_QUOTA_EXCEEDED;
- return read_type_struct_field( reader, desc, heap, ret, 0 );
+ HRESULT hr;
+ VOID *xret = NULL;
+
+ if (!ret)
+ {
+ if (!(xret = ws_alloc_zero( heap, get_field_size(desc) ))) return WS_E_QUOTA_EXCEEDED;
+ ret = xret;
+ }
+ hr = read_type_struct_field( reader, desc, heap, ret, 0 );
+ ws_free( heap, xret);
+ return hr;
}
static HRESULT read_param_array( struct reader *reader, const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap,
void **ret, ULONG *count )
{
- if (!ret && !(ret = ws_alloc_zero( heap, sizeof(void **) ))) return WS_E_QUOTA_EXCEEDED;
- return read_type_repeating_element( reader, desc, heap, ret, count );
+ HRESULT hr;
+ VOID *xret = NULL;
+
+ if (!ret)
+ {
+ if (!(xret = ws_alloc_zero( heap, sizeof(void **) ))) return WS_E_QUOTA_EXCEEDED;
+ ret = xret;
+ }
+ hr = read_type_repeating_element( reader, desc, heap, ret, count );
+ ws_free( heap, xret);
+ return hr;
}
static void set_array_len( const WS_PARAMETER_DESCRIPTION *params, ULONG count, ULONG index, ULONG len,
--
2.11.0
More information about the wine-patches
mailing list