widl: Fix for typelib generation when unaligned access to memory is not allowed

Marcus Meissner marcus at jet.franken.de
Sat Nov 13 14:14:08 CST 2010


On Sat, Nov 13, 2010 at 07:02:02PM +0100, André Hentschel wrote:
> caused a "Bus error" on sparc
> ---
>  tools/widl/write_msft.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
> index da4eb25..5175b73 100644
> --- a/tools/widl/write_msft.c
> +++ b/tools/widl/write_msft.c
> @@ -1208,7 +1208,11 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, const void *v
>          int len = strlen(s), seg_len = (len + 6 + 3) & ~0x3;
>          int offset = ctl2_alloc_segment(typelib, MSFT_SEG_CUSTDATA, seg_len, 0);
>          *((unsigned short *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset]) = vt;
> -        *((unsigned int *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+2]) = len;        
> +#ifdef ALLOW_UNALIGNED_ACCESS
> +        *((unsigned int *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+2]) = len;
> +#else
> +        memcpy(&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+2], &len, sizeof(len));
> +#endif
>          memcpy(&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+6], value, len);

Just do the memcpy unconditional.

Ciao, Marcus



More information about the wine-devel mailing list