[PATCH wayland 2/4] wl_array: Set data to null after free

Yong Bakos junk at humanoriented.com
Mon Sep 19 13:38:49 UTC 2016


On Sep 19, 2016, at 4:08 AM, Eric Engestrom <eric.engestrom at imgtec.com> wrote:
> 
> On Mon, Sep 19, 2016 at 11:59:03AM +0100, Eric Engestrom wrote:
>> On Fri, Sep 16, 2016 at 03:37:37PM -0700, Yong Bakos wrote:
>>> From: Yong Bakos <ybakos at humanoriented.com>
>>> 
>>> Explicitly set the data member to NULL during wl_array_release, preventing the
>>> dangling pointer but, more importantly, making it testable.
>>> 
>>> Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
>>> ---
>>> src/wayland-util.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/src/wayland-util.c b/src/wayland-util.c
>>> index 639ccf8..2efb133 100644
>>> --- a/src/wayland-util.c
>>> +++ b/src/wayland-util.c
>>> @@ -102,6 +102,7 @@ WL_EXPORT void
>>> wl_array_release(struct wl_array *array)
>>> {
>>> 	free(array->data);
>>> +	array->data = NULL;
>> 
>> If we add
>> 	array->size = 0;
>> 	array->alloc = 0;
>> 
>> we can then remove this comment from patch #1, right?
>> 	\note Leaves the array in an invalid state.
> 
> I somehow missed your cover-letter, but at least we agree :P
> I guess you'll send that as an independent patch later on?

I'm happy to do a v2, unless someone nack's the suggestion within a
day or two's time. Thanks, Eric.

yong



> Cheers,
>  Eric
> 
>> 
>> The series is good anyway, so it is:
>> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



More information about the wayland-devel mailing list