summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland/ecore_wl_dnd.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2013-11-18 07:56:13 +0000
committerChris Michael <cp.michael@samsung.com>2013-11-18 07:56:13 +0000
commiteb84475503da9f40d6a79eb2bff9c0a50805baee (patch)
tree3f446f482431e844134982c126dc646df0b5208f /src/lib/ecore_wayland/ecore_wl_dnd.c
parent5cefa00d0ad0f542ac53d38cbce4495884b09136 (diff)
Check for valid drag type before trying to strdup.
When deleting the drag, free any dupped strings. Hopefully this fixes Phab Ticket T471. Don't know for sure as I cannot reproduce the crash here :/ Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wayland/ecore_wl_dnd.c')
-rw-r--r--src/lib/ecore_wayland/ecore_wl_dnd.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_dnd.c b/src/lib/ecore_wayland/ecore_wl_dnd.c
index b1bf0664f3..1104f5bd0a 100644
--- a/src/lib/ecore_wayland/ecore_wl_dnd.c
+++ b/src/lib/ecore_wayland/ecore_wl_dnd.c
@@ -141,7 +141,7 @@ ecore_wl_dnd_selection_set(Ecore_Wl_Input *input, const char **types_offered)
141 for (type = types_offered; *type; type++) 141 for (type = types_offered; *type; type++)
142 { 142 {
143 t = wl_array_add(&input->data_types, sizeof(*t)); 143 t = wl_array_add(&input->data_types, sizeof(*t));
144 *t = strdup(*type); 144 if (t) *t = strdup(*type);
145 wl_data_source_offer(input->data_source, *t); 145 wl_data_source_offer(input->data_source, *t);
146 } 146 }
147 147
@@ -374,9 +374,13 @@ ecore_wl_dnd_drag_types_set(Ecore_Wl_Input *input, const char **types_offered)
374 /* add these types to the data source */ 374 /* add these types to the data source */
375 for (type = types_offered; *type; type++) 375 for (type = types_offered; *type; type++)
376 { 376 {
377 if (!*type) continue;
377 t = wl_array_add(&input->data_types, sizeof(*t)); 378 t = wl_array_add(&input->data_types, sizeof(*t));
378 *t = strdup(*type); 379 if (t)
379 wl_data_source_offer(input->data_source, *t); 380 {
381 *t = strdup(*type);
382 wl_data_source_offer(input->data_source, *t);
383 }
380 } 384 }
381} 385}
382 386
@@ -563,6 +567,8 @@ _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device EINA_UNUS
563void 567void
564_ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source) 568_ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source)
565{ 569{
570 char **t;
571
566 LOGFN(__FILE__, __LINE__, __FUNCTION__); 572 LOGFN(__FILE__, __LINE__, __FUNCTION__);
567 573
568 if (!source) return; 574 if (!source) return;
@@ -570,6 +576,8 @@ _ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source)
570 if (source->refcount == 0) 576 if (source->refcount == 0)
571 { 577 {
572 wl_data_offer_destroy(source->data_offer); 578 wl_data_offer_destroy(source->data_offer);
579 for (t = source->types.data; *t; t++)
580 free(*t);
573 wl_array_release(&source->types); 581 wl_array_release(&source->types);
574 free(source); 582 free(source);
575 } 583 }
@@ -779,7 +787,8 @@ _ecore_wl_dnd_offer_cb_offer(void *data, struct wl_data_offer *data_offer EINA_U
779 LOGFN(__FILE__, __LINE__, __FUNCTION__); 787 LOGFN(__FILE__, __LINE__, __FUNCTION__);
780 788
781 if (!(source = data)) return; 789 if (!(source = data)) return;
790 if (!type) return;
782 791
783 t = wl_array_add(&source->types, sizeof(*t)); 792 t = wl_array_add(&source->types, sizeof(*t));
784 *t = strdup(type); 793 if (t) *t = strdup(type);
785} 794}