From daf10dd2badad14742fa06e4c511379e6f163840 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Fri, 20 Mar 2015 22:07:27 -0400 Subject: [PATCH] ecore_wayland: Check for nulls before wayland calls Summary: Wayland API routines by policy do not check input parameters for invalid values. In particular, many calls are wrappers through wl_proxy_marshal, which derefs its first argument without a check. So, for all wayland calls, always null check the first argument. Reviewers: zmike, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2211 --- src/lib/ecore_wayland/ecore_wl_subsurf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/ecore_wayland/ecore_wl_subsurf.c b/src/lib/ecore_wayland/ecore_wl_subsurf.c index f34febf08d..3c92ce8c4e 100644 --- a/src/lib/ecore_wayland/ecore_wl_subsurf.c +++ b/src/lib/ecore_wayland/ecore_wl_subsurf.c @@ -71,8 +71,13 @@ _ecore_wl_subsurf_destroy(Ecore_Wl_Subsurf *ess) { Ecore_Wl_Window *parent; - wl_subsurface_destroy(ess->subsurface); - wl_surface_destroy(ess->surface); + if (!ess) return; + + if (ess->subsurface) + wl_subsurface_destroy(ess->subsurface); + + if (ess->surface) + wl_surface_destroy(ess->surface); parent = ess->parent_win; parent->subsurfs = (Ecore_Wl_Subsurf *)eina_inlist_remove @@ -120,6 +125,7 @@ ecore_wl_subsurf_position_set(Ecore_Wl_Subsurf *ess, int x, int y) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ess) return; + if (!ess->subsurface) return; if ((x == ess->x) && (y == ess->y)) return; @@ -148,6 +154,7 @@ ecore_wl_subsurf_place_above(Ecore_Wl_Subsurf *ess, struct wl_surface *surface) if (!ess) return; if (!surface) return; + if (!ess->subsurface) return; wl_subsurface_place_above(ess->subsurface, surface); } @@ -159,6 +166,7 @@ ecore_wl_subsurf_place_below(Ecore_Wl_Subsurf *ess, struct wl_surface *surface) if (!ess) return; if (!surface) return; + if (!ess->subsurface) return; wl_subsurface_place_below(ess->subsurface, surface); } @@ -169,6 +177,7 @@ ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ess) return; + if (!ess->subsurface) return; val = !!val; if (val == ess->sync) return; @@ -189,10 +198,13 @@ ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, i LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ess) return; + if (!ess->surface) return; if ((w > 0) && (h > 0)) { region = wl_compositor_create_region(_ecore_wl_compositor_get()); + if (!region) return; + wl_region_add(region, x, y, w, h); wl_surface_set_opaque_region(ess->surface, region); wl_region_destroy(region);