[PATCH 1/8] server: Allocate extra_bytes separatelly from window struct.

Jacek Caban jacek at codeweavers.com
Tue Feb 8 06:10:40 CST 2022


On 2/8/22 12:45, Huw Davies wrote:
> On Tue, Feb 08, 2022 at 12:26:46PM +0100, Jacek Caban wrote:
>> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
>> ---
>> We will eventually use window_shared for that when it's ready.
>>
>>   server/window.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/server/window.c b/server/window.c
>> index 7ea91d2a7dc..366f1fd9c44 100644
>> --- a/server/window.c
>> +++ b/server/window.c
>> @@ -93,7 +93,7 @@ struct window
>>       int              prop_alloc;      /* number of allocated window properties */
>>       struct property *properties;      /* window properties array */
>>       int              nb_extra_bytes;  /* number of extra bytes */
>> -    char             extra_bytes[1];  /* extra bytes storage */
>> +    char            *extra_bytes;     /* extra bytes storage */
>>   };
>>   
>>   /* flags that can be set by the client */
>> @@ -483,7 +483,8 @@ static struct window *create_window( struct window *parent, struct window *owner
>>           goto failed;
>>       }
>>   
>> -    if (!(win = mem_alloc( sizeof(*win) + extra_bytes - 1 ))) goto failed;
>> +    if (!(win = mem_alloc( sizeof(*win) ))) goto failed;
>> +    if (extra_bytes && !(win->extra_bytes = mem_alloc( extra_bytes ))) goto failed;
>>       if (!(win->handle = alloc_user_handle( win, USER_WINDOW ))) goto failed;
> Don't you need to NULL-init win->extra_bytes in the !extra_bytes case (at
> the very least for the failed: block below).


Yes, I messed it up. It would be probably cleaner to move part of patch 
2 here anyway, I will send a fixed version.


Thanks,

Jacek




More information about the wine-devel mailing list