Hans Leidekker : webservices: Pass exact size in read_type_struct_field.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Apr 6 11:12:04 CDT 2016


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Apr  6 15:55:50 2016 +0200

webservices: Pass exact size in read_type_struct_field.

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

---

 dlls/webservices/reader.c              | 19 +++++++++++++------
 dlls/webservices/webservices_private.h |  1 -
 dlls/webservices/writer.c              |  2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index b61c50c..7559da0 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -2579,6 +2579,8 @@ static HRESULT read_type_repeating_element( struct reader *reader, const WS_FIEL
     ULONG item_size, nb_items = 0, nb_allocated = 1, offset = 0;
     char *buf;
 
+    if (size != sizeof(void *)) return E_INVALIDARG;
+
     if (desc->itemRange)
         FIXME( "ignoring range (%u-%u)\n", desc->itemRange->minItemCount, desc->itemRange->maxItemCount );
 
@@ -2627,7 +2629,7 @@ static HRESULT read_type_repeating_element( struct reader *reader, const WS_FIEL
         /* fall through */
 
     case WS_READ_OPTIONAL_POINTER:
-        if (size < sizeof(void *)) return E_INVALIDARG;
+        if (size != sizeof(void *)) return E_INVALIDARG;
         *ret = buf;
         break;
 
@@ -2686,14 +2688,20 @@ static WS_READ_OPTION map_field_options( WS_TYPE type, ULONG options )
 }
 
 static HRESULT read_type_struct_field( struct reader *reader, const WS_FIELD_DESCRIPTION *desc,
-                                       WS_HEAP *heap, char *buf, ULONG size )
+                                       WS_HEAP *heap, char *buf )
 {
     char *ptr = buf + desc->offset;
     WS_READ_OPTION option;
+    ULONG size;
     HRESULT hr;
 
     if (!(option = map_field_options( desc->type, desc->options ))) return E_INVALIDARG;
 
+    if (option == WS_READ_REQUIRED_VALUE)
+        size = get_type_size( desc->type, desc->typeDescription );
+    else
+        size = sizeof(void *);
+
     switch (desc->mapping)
     {
     case WS_ATTRIBUTE_FIELD_MAPPING:
@@ -2750,7 +2758,7 @@ static HRESULT read_type_struct( struct reader *reader, WS_TYPE_MAPPING mapping,
                                  const WS_STRUCT_DESCRIPTION *desc, WS_READ_OPTION option,
                                  WS_HEAP *heap, void *ret, ULONG size )
 {
-    ULONG i, field_size;
+    ULONG i;
     HRESULT hr;
     char *buf;
 
@@ -2766,7 +2774,7 @@ static HRESULT read_type_struct( struct reader *reader, WS_TYPE_MAPPING mapping,
     {
     case WS_READ_REQUIRED_POINTER:
     case WS_READ_OPTIONAL_POINTER:
-        if (size < sizeof(void *)) return E_INVALIDARG;
+        if (size != sizeof(void *)) return E_INVALIDARG;
         if (!(buf = ws_alloc_zero( heap, desc->size ))) return WS_E_QUOTA_EXCEEDED;
         break;
 
@@ -2782,8 +2790,7 @@ static HRESULT read_type_struct( struct reader *reader, WS_TYPE_MAPPING mapping,
 
     for (i = 0; i < desc->fieldCount; i++)
     {
-        field_size = get_field_size( desc, i );
-        if ((hr = read_type_struct_field( reader, desc->fields[i], heap, buf, field_size )) != S_OK)
+        if ((hr = read_type_struct_field( reader, desc->fields[i], heap, buf )) != S_OK)
             break;
     }
 
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index 548da06..c286fd2 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -32,7 +32,6 @@ WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
 WS_XML_UTF8_TEXT *alloc_utf8_text( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
 HRESULT append_attribute( WS_XML_ELEMENT_NODE *, WS_XML_ATTRIBUTE * ) DECLSPEC_HIDDEN;
 void free_attribute( WS_XML_ATTRIBUTE * ) DECLSPEC_HIDDEN;
-ULONG get_field_size( const WS_STRUCT_DESCRIPTION *, ULONG ) DECLSPEC_HIDDEN;
 
 struct node
 {
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 8f6c6aa..e9ef7b1 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -1378,7 +1378,7 @@ static HRESULT write_type_struct_field( struct writer *writer, const WS_FIELD_DE
     return S_OK;
 }
 
-ULONG get_field_size( const WS_STRUCT_DESCRIPTION *desc, ULONG index )
+static ULONG get_field_size( const WS_STRUCT_DESCRIPTION *desc, ULONG index )
 {
     if (index < desc->fieldCount - 1) return desc->fields[index + 1]->offset - desc->fields[index]->offset;
     return desc->size - desc->fields[index]->offset;




More information about the wine-cvs mailing list