Hans Leidekker : webservices: Always create a copy of strings to insert in the dictionary.

Alexandre Julliard julliard at winehq.org
Tue Oct 3 15:39:53 CDT 2017


Module: wine
Branch: master
Commit: 3076f5e3fbcf610320a37b6673a48553fe27b9be
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3076f5e3fbcf610320a37b6673a48553fe27b9be

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Tue Oct  3 16:14:44 2017 +0200

webservices: Always create a copy of strings to insert in the dictionary.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/webservices/channel.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index ef37095..92569fd 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -1208,14 +1208,24 @@ static HRESULT CALLBACK dict_cb( void *state, const WS_XML_STRING *str, BOOL *fo
 {
     struct dictionary *dict = state;
     HRESULT hr = S_OK;
+    BYTE *bytes;
     int index;
 
-    if ((index = find_string( dict, str->bytes, str->length, id )) == -1 ||
-        (hr = insert_string( dict, str->bytes, str->length, index, id )) == S_OK)
+    if ((index = find_string( dict, str->bytes, str->length, id )) == -1)
+    {
+        *found = TRUE;
+        return S_OK;
+    }
+
+    if (!(bytes = heap_alloc( str->length ))) return E_OUTOFMEMORY;
+    memcpy( bytes, str->bytes, str->length );
+    if ((hr = insert_string( dict, bytes, str->length, index, id )) == S_OK)
     {
         *found = TRUE;
         return S_OK;
     }
+    heap_free( bytes );
+
     *found = FALSE;
     return hr;
 }
@@ -1672,6 +1682,7 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
         }
         if ((hr = insert_string( dict, bytes, size, index, NULL )) != S_OK)
         {
+            heap_free( bytes );
             clear_dict( dict );
             return hr;
         }




More information about the wine-cvs mailing list