diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-08-06 19:20:03 +0100 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-08-06 19:20:03 +0100 |
commit | e96cff8503a5f9122789c7432742e0353b8ccb2f (patch) | |
tree | d2710104ebf42ad9c33c3e56b70c85306279ed20 /src | |
parent | 8c76ff3e32d7e2e5b0956dbd27e076fa84e9efce (diff) |
xwayland dnd - handle names not being allocated
fix CID 1403921
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/xwayland/dnd.c | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/src/modules/xwayland/dnd.c b/src/modules/xwayland/dnd.c index b18f4c0..42f5f28 100644 --- a/src/modules/xwayland/dnd.c +++ b/src/modules/xwayland/dnd.c | |||
@@ -186,52 +186,56 @@ _xwl_fixes_selection_notify(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_X_Even | |||
186 | Ecore_X_Atom *types = (void*)data; | 186 | Ecore_X_Atom *types = (void*)data; |
187 | 187 | ||
188 | names = malloc(num * sizeof(void*)); | 188 | names = malloc(num * sizeof(void*)); |
189 | namelist = eina_array_new(num); | 189 | if (names) |
190 | for (i = 0; i < num; i++) | ||
191 | { | 190 | { |
192 | char *name; | 191 | namelist = eina_array_new(num); |
193 | 192 | for (i = 0; i < num; i++) | |
194 | if (types[i] == string_atom) | ||
195 | { | 193 | { |
196 | name = names[i] = strdup("UTF8_STRING"); | 194 | char *name; |
197 | eina_array_push(namelist, eina_stringshare_add(WL_TEXT_STR)); | 195 | |
196 | if (types[i] == string_atom) | ||
197 | { | ||
198 | name = names[i] = strdup("UTF8_STRING"); | ||
199 | eina_array_push(namelist, eina_stringshare_add(WL_TEXT_STR)); | ||
200 | } | ||
201 | else | ||
202 | names[i] = name = ecore_x_atom_name_get(types[i]); | ||
203 | DBG("XWL TARGET: %s", name); | ||
204 | eina_array_push(namelist, eina_stringshare_add(name)); | ||
205 | } | ||
206 | if (num > 3) | ||
207 | { | ||
208 | ecore_x_window_prop_property_set(e_comp->cm_selection, | ||
209 | ECORE_X_ATOM_XDND_TYPE_LIST, ECORE_X_ATOM_ATOM, 32, names, num); | ||
198 | } | 210 | } |
199 | else | ||
200 | names[i] = name = ecore_x_atom_name_get(types[i]); | ||
201 | DBG("XWL TARGET: %s", name); | ||
202 | eina_array_push(namelist, eina_stringshare_add(name)); | ||
203 | } | ||
204 | if (num > 3) | ||
205 | { | ||
206 | ecore_x_window_prop_property_set(e_comp->cm_selection, | ||
207 | ECORE_X_ATOM_XDND_TYPE_LIST, ECORE_X_ATOM_ATOM, 32, names, num); | ||
208 | } | 211 | } |
209 | |||
210 | free(data); | 212 | free(data); |
211 | } | 213 | } |
212 | evas_pointer_canvas_xy_get(e_comp->evas, &x, &y); | 214 | if (names) |
213 | e_comp_wl->drag_client = e_pixmap_find_client(E_PIXMAP_TYPE_X, ev->owner); | 215 | { |
214 | if (!e_comp_wl->drag_client) e_comp_wl->drag_client = e_comp_wl->ptr.ec; | 216 | evas_pointer_canvas_xy_get(e_comp->evas, &x, &y); |
215 | e_comp_wl->drag = e_drag_new(x, y, (const char**)names, num, NULL, 0, NULL, _xwayland_drop); | 217 | e_comp_wl->drag_client = e_pixmap_find_client(E_PIXMAP_TYPE_X, ev->owner); |
216 | e_comp_wl->drag->button_mask = evas_pointer_button_down_mask_get(e_comp->evas); | 218 | if (!e_comp_wl->drag_client) e_comp_wl->drag_client = e_comp_wl->ptr.ec; |
217 | ecore_x_window_move_resize(e_comp->cm_selection, 0, 0, e_comp->w, e_comp->h); | 219 | e_comp_wl->drag = e_drag_new(x, y, (const char**)names, num, NULL, 0, NULL, _xwayland_drop); |
218 | ecore_x_window_show(e_comp->cm_selection); | 220 | e_comp_wl->drag->button_mask = evas_pointer_button_down_mask_get(e_comp->evas); |
219 | e_drag_start(e_comp_wl->drag, x, y); | 221 | ecore_x_window_move_resize(e_comp->cm_selection, 0, 0, e_comp->w, e_comp->h); |
220 | if (e_comp_wl->ptr.ec) | 222 | ecore_x_window_show(e_comp->cm_selection); |
221 | e_comp_wl_data_device_send_enter(e_comp_wl->ptr.ec); | 223 | e_drag_start(e_comp_wl->drag, x, y); |
222 | e_comp_canvas_feed_mouse_up(0); | 224 | if (e_comp_wl->ptr.ec) |
223 | source = e_comp_wl_data_manager_source_create(e_comp_wl->xwl_client, | 225 | e_comp_wl_data_device_send_enter(e_comp_wl->ptr.ec); |
224 | e_comp_wl->mgr.resource, 0); | 226 | e_comp_canvas_feed_mouse_up(0); |
225 | source->current_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; | 227 | source = e_comp_wl_data_manager_source_create(e_comp_wl->xwl_client, |
226 | source->dnd_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; | 228 | e_comp_wl->mgr.resource, 0); |
227 | e_comp_wl->drag_source = source; | 229 | source->current_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; |
228 | source->target = _xwayland_target_send; | 230 | source->dnd_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; |
229 | source->send = _xwayland_send_send; | 231 | e_comp_wl->drag_source = source; |
230 | source->cancelled = _xwayland_cancelled_send; | 232 | source->target = _xwayland_target_send; |
231 | source->mime_types = namelist; | 233 | source->send = _xwayland_send_send; |
232 | for (i = 0; i < num; i++) | 234 | source->cancelled = _xwayland_cancelled_send; |
233 | free(names[i]); | 235 | source->mime_types = namelist; |
234 | free(names); | 236 | for (i = 0; i < num; i++) free(names[i]); |
237 | free(names); | ||
238 | } | ||
235 | } | 239 | } |
236 | else | 240 | else |
237 | { | 241 | { |