From 59cf913488f31e3986e0f703cd480b20add47070 Mon Sep 17 00:00:00 2001 From: Hyoyoung Chang Date: Fri, 8 Oct 2010 15:45:01 +0900 Subject: [PATCH] [cnp_helper] Make sure handle data length correctly on text length. --- src/lib/elm_cnp_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/elm_cnp_helper.c b/src/lib/elm_cnp_helper.c index 06dbb27..d9d5530 100644 --- a/src/lib/elm_cnp_helper.c +++ b/src/lib/elm_cnp_helper.c @@ -98,7 +98,7 @@ static Eina_Bool selection_clear(void *udata __UNUSED__, int type, void *event); //static Eina_Bool selection_request(void *udata __UNUSED__, int type, void *event); static Eina_Bool selection_notify(void *udata __UNUSED__, int type, void *event); static char *remove_tags(const char *p, int *len); -static char *mark_up(const char *start, int *lenp); +static char *mark_up(const char *start, int inlen, int *lenp); static Evas_Object *image_provider(void *images, Evas_Object *entry, const char *item); static void @@ -642,9 +642,7 @@ notify_handler_text(struct _elm_cnp_selection *sel, data = notify->data; cnp_debug("Notify handler text %d %d %p\n",data->format,data->length,data->data); - str = mark_up((char*)data->data, NULL); - // FIXME: should it be cutted to fit length?? -// str[data->length] = '\0'; + str = mark_up((char*)data->data, data->length, NULL); cnp_debug("String is %s (from %s)\n",str,data->data); elm_entry_entry_insert(sel->requestwidget, str); free(str); @@ -1022,14 +1020,17 @@ remove_tags(const char *p, int *len){ /* Mark up */ static char * -mark_up(const char *start, int *lenp){ +mark_up(const char *start, int inlen, int *lenp){ int l,i; const char *p; char *q,*ret; + char *endp = NULL; if (!start) return NULL; + if (inlen >= 0) + endp = start + inlen; /* First pass: Count characters */ - for (l = 0, p = start ; *p ; p ++) + for (l = 0, p = start ; (!endp || (p < endp)) && *p ; p ++) { for (i = 0 ; i < N_ESCAPES ; i ++) { -- 2.7.4