From 6859da938fe4c2d994fc8174b1c2df9376835ca5 Mon Sep 17 00:00:00 2001 From: raster Date: Mon, 9 Apr 2012 08:06:33 +0000 Subject: [PATCH] handle malloc failure and free string if sel->datacb is not null git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69965 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_cnp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c index ab1a7fe..263440d 100644 --- a/src/lib/elm_cnp.c +++ b/src/lib/elm_cnp.c @@ -779,6 +779,7 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify) data = notify->data; str = malloc(sizeof(char) * (data->length + 1)); + if (!str) return 0; strncpy(str, (char *)data->data, data->length); str[data->length] = '\0'; @@ -791,11 +792,13 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify) ddata.data = data->data; ddata.len = data->length; sel->datacb(sel->udata, sel->widget, &ddata); + free(str); return 0; } - cnp_debug("Notify handler text %d %d %p\n", data->format,data->length, data->data); - mkupstr = _elm_util_text_to_mkup((const char *) str); + cnp_debug("Notify handler text %d %d %p\n", data->format, + data->length, data->data); + mkupstr = _elm_util_text_to_mkup((const char *)str); cnp_debug("String is %s (from %s)\n", str, data->data); _elm_entry_entry_paste(sel->requestwidget, mkupstr); free(str); -- 2.7.4