[PATCH weston 1/2] clients: Don't crash when compositor doesn't support drag and drop

Derek Foreman derekf at osg.samsung.com
Thu Apr 20 19:31:36 UTC 2017


display_create_data_source() can return NULL when there's no data device
manager present.  Instead of carrying on blindly, test its return value.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 clients/editor.c   | 3 +++
 clients/terminal.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/clients/editor.c b/clients/editor.c
index b63c5628..b557659d 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -636,6 +636,9 @@ editor_copy_cut(struct editor *editor, struct input *input, bool cut)
 
 		editor->selection =
 			display_create_data_source(editor->display);
+		if (!editor->selection)
+			return;
+
 		wl_data_source_offer(editor->selection,
 				     "text/plain;charset=utf-8");
 		wl_data_source_add_listener(editor->selection,
diff --git a/clients/terminal.c b/clients/terminal.c
index 274ced09..16a44954 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2264,6 +2264,9 @@ terminal_copy(struct terminal *terminal, struct input *input)
 {
 	terminal->selection =
 		display_create_data_source(terminal->display);
+	if (!terminal->selection)
+		return;
+
 	wl_data_source_offer(terminal->selection,
 			     "text/plain;charset=utf-8");
 	wl_data_source_add_listener(terminal->selection,
-- 
2.11.0



More information about the wayland-devel mailing list