[3/6] widl: Avoid generating negative offsets for conformant arrays of strings. Take 2.

Dmitry Timoshkov dmitry at baikal.ru
Wed Apr 2 04:37:37 CDT 2014


This version of the patch limits the changes to conformant arrays of
strings in order to avoid unwanted changes to other pointer types.

This matches midl output and avoids crashes in the string array tests
under Windows. It appears that 32-bit rpcrt4 doesn't support negative
offsets in the array descriptions and crashes in the unmarshalling phase,
while 64-bit rpcrt4 handles negative offsets just fine in all cases.
I decided to generate same output for both 32-bit and 64-bit code and
follow what midl does in this case.
---
 tools/widl/typegen.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 881f161..37222d1 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -3581,12 +3581,26 @@ static unsigned int write_type_tfs(FILE *file, int indent,
     case TGT_POINTER:
     {
         enum type_context ref_context;
+        type_t *ref = type_pointer_get_ref(type);
+
         if (context == TYPE_CONTEXT_TOPLEVELPARAM)
             ref_context = TYPE_CONTEXT_PARAM;
         else if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
             ref_context = TYPE_CONTEXT_CONTAINER;
         else
             ref_context = context;
+
+        if (is_string_type(attrs, type) && is_conformant_array(ref))
+        {
+            if (context != TYPE_CONTEXT_CONTAINER_NO_POINTERS)
+                write_pointer_tfs(file, attrs, type, *typeformat_offset + 4, context, typeformat_offset);
+
+            offset = write_type_tfs(file, indent, attrs, ref, name, ref_context, typeformat_offset);
+            if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
+                return 0;
+            return offset;
+        }
+
         offset = write_type_tfs( file, indent, attrs, type_pointer_get_ref(type), name,
                                  ref_context, typeformat_offset);
         if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
-- 
1.9.1




More information about the wine-patches mailing list