summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2020-03-26 10:47:34 -0400
committerMike Blumenkrantz <zmike@samsung.com>2020-03-26 10:47:34 -0400
commite0f5e80f7831c930d432c9991d831cbd4f48babd (patch)
tree95e8d48579483ed63d8ecb380de1dd2c61dcbc3c /src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
parent19c57d38dbfb24058a4c7f5e044c86c2af301df6 (diff)
fix segfault when there is no text in clipboard
Test Plan: cnp a clipboard content without text Reviewers: zmike Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11565
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/win32/ecore_evas_win32.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
index 7f6eb98e48..41a0fad65e 100644
--- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
+++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
@@ -1292,22 +1292,28 @@ _ecore_evas_win32_selection_request(Ecore_Evas *ee EINA_UNUSED, unsigned int sea
1292 Eina_Rw_Slice slice; 1292 Eina_Rw_Slice slice;
1293 1293
1294 data = ecore_win32_clipboard_get((Ecore_Win32_Window *)ee->prop.window, &size, mime_type); 1294 data = ecore_win32_clipboard_get((Ecore_Win32_Window *)ee->prop.window, &size, mime_type);
1295 if (eina_str_has_prefix(mime_type, "text/")) 1295 if (size != 0)
1296 { 1296 {
1297 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here. 1297 if (eina_str_has_prefix(mime_type, "text/"))
1298 slice.len = size + 1; 1298 {
1299 slice.mem = eina_memdup(data, size, EINA_TRUE); 1299 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
1300 slice.len = size + 1;
1301 slice.mem = eina_memdup(data, size, EINA_TRUE);
1302 free(data);
1303 }
1304 else
1305 {
1306 slice.len = size;
1307 slice.mem = data;
1308 }
1309 content = eina_content_new(eina_rw_slice_slice_get(slice), mime_type);
1310 if (!content) // construction can fail because of some validation reasons
1311 eina_promise_reject(promise, ecore_evas_no_matching_type);
1312 else
1313 eina_promise_resolve(promise, eina_value_content_init(content));
1300 } 1314 }
1301 else 1315 else
1302 {
1303 slice.len = size;
1304 slice.mem = data;
1305 }
1306 content = eina_content_new(eina_rw_slice_slice_get(slice), mime_type);
1307 if (!content) // construction can fail because of some validation reasons
1308 eina_promise_reject(promise, ecore_evas_no_matching_type); 1316 eina_promise_reject(promise, ecore_evas_no_matching_type);
1309 else
1310 eina_promise_resolve(promise, eina_value_content_init(content));
1311 } 1317 }
1312 return future; 1318 return future;
1313} 1319}