[PATCH weston 2/2] wayland-server: Avoid deferencing a NULL pointer in error case
Jason Ekstrand
jason at jlekstrand.net
Thu Mar 28 12:29:13 PDT 2013
Both patches in this series look good to me.
--Jason Ekstrand
On Mar 28, 2013 1:49 PM, "Rob Bradford" <robert.bradford at intel.com> wrote:
> From: Rob Bradford <rob at linux.intel.com>
>
> Reorder the error handling in the case that closure is NULL due to ENOMEM
> to
> ensure that we can safely call wl_closure_lookup_objects on the second
> test.
> Prior to this reordering the closure would be deferenced in the ENOMEM case
> due to the invocation of the second half of the logical OR check.
> ---
> src/wayland-server.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index dcb4435..384b465 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -260,8 +260,11 @@ wl_client_connection_data(int fd, uint32_t mask, void
> *data)
> &client->objects,
> message);
> len -= size;
>
> - if ((closure == NULL && errno == EINVAL) ||
> - wl_closure_lookup_objects(closure, &client->objects) <
> 0) {
> + if (closure == NULL && errno == ENOMEM) {
> + wl_resource_post_no_memory(resource);
> + break;
> + } else if ((closure == NULL && errno == EINVAL) ||
> + wl_closure_lookup_objects(closure,
> &client->objects) < 0) {
> wl_resource_post_error(client->display_resource,
>
> WL_DISPLAY_ERROR_INVALID_METHOD,
> "invalid arguments for %s@
> %u.%s",
> @@ -269,9 +272,6 @@ wl_client_connection_data(int fd, uint32_t mask, void
> *data)
> object->id,
> message->name);
> break;
> - } else if (closure == NULL && errno == ENOMEM) {
> - wl_resource_post_no_memory(resource);
> - break;
> }
>
> if (wl_debug)
> --
> 1.8.1.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130328/3c2b569d/attachment.html>
More information about the wayland-devel
mailing list