oleaut32: Fix SAFEARRAY marshalling on 64-bit platforms.

Alexandre Julliard julliard at winehq.org
Mon Feb 9 08:33:39 CST 2009


Rob Shearman <robertshearman at gmail.com> writes:

> 2009/2/9 Alexandre Julliard <julliard at winehq.org>:
>> Rob Shearman <robertshearman at gmail.com> writes:
>>
>>> @@ -874,8 +874,8 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buf
>>>
>>>          *(ULONG *)Buffer = ulCellCount;
>>>          Buffer += sizeof(ULONG);
>>> -        *(ULONG_PTR *)Buffer = (ULONG_PTR)psa->pvData;
>>> -        Buffer += sizeof(ULONG_PTR);
>>> +        *(ULONG *)Buffer = (ULONG)(ULONG_PTR)psa->pvData;
>>> +        Buffer += sizeof(ULONG);
>>
>> Wouldn't this break if the pointer happens to be 4Gb-aligned?
>
> It would write 0 into memory, yes, but the value written here isn't
> used during unmarshalling so it is fine and I believe this matches
> what native does.

The exact value doesn't matter, but it seems to me that it won't get
unmarshaled correctly if the value happens to be 0. Am I missing
something?

> If we wanted to relax the tests, we could change this to "*(ULONG
> *)Buffer = psa->pvData ? 0x2 : 0x0" and check the value during
> unmarshalling to be totally correct with the NDR-formatted data that
> we are writing.

Without relaxing the tests you could still write the pointer and only
store 0x2 when you would have stored 0 for a non-null pointer.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list