From: raster Date: Mon, 9 Apr 2012 08:06:33 +0000 (+0000) Subject: handle malloc failure and free string if sel->datacb is not null X-Git-Tag: sbs/armel/slp2-target~36^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6859da938fe4c2d994fc8174b1c2df9376835ca5;p=framework%2Fuifw%2Felementary.git 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 --- 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);