From 946ee4cae01ce0d7e81f069517d6272ff1b1fb15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Paku=C5=82a=20vel=20Rutka?= <m.pakula@samsung.com>
Date: Mon, 21 May 2012 15:09:06 +0200
Subject: [PATCH] elementary/elm_cnp fix non-NULL-terminated string bug

This fixes a bug occuring when copying and pasting data
using ELM_SEL_FORMAT_HTML.
---
 trunk/elementary/src/lib/elm_cnp.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/trunk/elementary/src/lib/elm_cnp.c b/trunk/elementary/src/lib/elm_cnp.c
index 07a6ce3..aa756e3 100644
--- a/trunk/elementary/src/lib/elm_cnp.c
+++ b/trunk/elementary/src/lib/elm_cnp.c
@@ -999,21 +999,21 @@ notify_handler_html(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify)
 
    cnp_debug("Got some HTML: Checking encoding is useful\n");
    data = notify->data;
+   char *stripstr = malloc(sizeof(char) * (data->length + 1));
+   strncpy(stripstr, (char *)data->data, data->length);
+   stripstr[data->length] = '\0';
 
    if (sel->datacb)
      {
         Elm_Selection_Data ddata;
         ddata.x = ddata.y = 0;
         ddata.format = ELM_SEL_FORMAT_HTML;
-        ddata.data = data->data;
-        ddata.len = data->length;
+        ddata.data = stripstr;
+        ddata.len = strlen(stripstr);
         sel->datacb(sel->udata, sel->widget, &ddata);
         return 0;
      }
 
-   char *stripstr = malloc(sizeof(char) * (data->length + 1));
-   strncpy(stripstr, (char *)data->data, data->length);
-   stripstr[data->length] = '\0';
    cnp_debug("String is %s (%d bytes)\n", stripstr, data->length);
    _elm_entry_entry_paste(sel->requestwidget, stripstr);
    free(stripstr);
-- 
1.7.5.4

