[PATCH] xwayland: Check return of xcb_get_property_reply() before deref
Marek Chalupa
mchqwerty at gmail.com
Fri Jul 10 01:50:43 PDT 2015
On 07/10/2015 06:30 AM, Bryce Harrington wrote:
> From the man pages it appears this routine can return NULL on certain
> error conditions.
>
> Suggested by Marek Chalupa
>
> Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> ---
> xwayland/selection.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/xwayland/selection.c b/xwayland/selection.c
> index 451b915..2f60c0e 100644
> --- a/xwayland/selection.c
> +++ b/xwayland/selection.c
> @@ -111,6 +111,8 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
> 0x1fffffff /* length */);
>
> reply = xcb_get_property_reply(wm->conn, cookie, NULL);
> + if (reply == NULL)
> + return;
>
> dump_property(wm, wm->atom.wl_selection, reply);
>
> @@ -184,6 +186,8 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
> 4096 /* length */);
>
> reply = xcb_get_property_reply(wm->conn, cookie, NULL);
> + if (reply == NULL)
> + return;
>
> dump_property(wm, wm->atom.wl_selection, reply);
>
> @@ -236,6 +240,8 @@ weston_wm_get_selection_data(struct weston_wm *wm)
> 0x1fffffff /* length */);
>
> reply = xcb_get_property_reply(wm->conn, cookie, NULL);
> + if (reply == NULL)
> + return;
>
> if (reply->type == wm->atom.incr) {
> dump_property(wm, wm->atom.wl_selection, reply);
>
Maybe we could leave dump_property before the check and return, because
dump_property allows reply to be NULL and so user would know where the
selection failed.
Looking into the code, when making this change it would be nice to
refactor the code a little bit (e.g. line 240 and 244).
Is it better to follow-up or squash it into this patch?
Reviewed-by: Marek Chalupa <mchqwerty at gmail.com>
Cheers,
Marek
More information about the wayland-devel
mailing list