raster pushed a commit to branch master.
commit 975c6fd71c091199a6063173f4ac61185c773997
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date: Wed May 8 12:50:09 2013 +0900
elm cnp bugs waiting to happen - not 0 terminating cnp strings in some
cases.
---
src/lib/elm_cnp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index a4c1d96..362cbc6 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -1588,13 +1588,14 @@ _x11_elm_cnp_selection_set(Evas_Object *obj,
Elm_Sel_Type selection, Elm_Sel_For
if (format == ELM_SEL_FORMAT_IMAGE)
{
// selbuf is actual image data, not text/string
- sel->selbuf = malloc(buflen);
+ sel->selbuf = malloc(buflen + 1);
if (!sel->selbuf)
{
elm_object_cnp_selection_clear(obj, selection);
return EINA_FALSE;
}
memcpy(sel->selbuf, selbuf, buflen);
+ sel->selbuf[buflen] = 0;
}
else
sel->selbuf = strdup((char*)selbuf);
@@ -2139,7 +2140,7 @@ struct _Local_Selinfo
{
Elm_Sel_Format format;
struct {
- void *buf;
+ char *buf;
size_t size;
} sel;
struct {
@@ -2218,10 +2219,11 @@ _local_elm_cnp_selection_set(Evas_Object *obj
__UNUSED__,
if (_local_selinfo[selection].sel.buf)
free(_local_selinfo[selection].sel.buf);
_local_selinfo[selection].format = format;
- _local_selinfo[selection].sel.buf = malloc(buflen);
+ _local_selinfo[selection].sel.buf = malloc(buflen + 1);
if (_local_selinfo[selection].sel.buf)
{
memcpy(_local_selinfo[selection].sel.buf, selbuf, buflen);
+ _local_selinfo[selection].sel.buf[buflen] = 0;
_local_selinfo[selection].sel.size = buflen;
}
else
--
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may