From aa8a1eb727672e0ba17ff9475c72a6dce201e2e6 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 13 Jan 2013 14:11:42 +0000 Subject: [PATCH] ecore_x/xcb: fix use of uninitialized var + leak--. Fix #1786 SVN revision: 82730 --- ChangeLog | 6 ++++++ src/lib/ecore_x/xcb/ecore_xcb_selection.c | 5 +++-- src/lib/ecore_x/xlib/ecore_x_selection.c | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f02102ab46..3444004eaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-01-13 Boris Faure (billiob) + + * Fixed condition based on uninitialized value in ecore_x_selection + (both xlib and xcb). + * Fixed a leaked when no selection converter matches. + 2013-01-11 Tom Hacohen (TAsn) * Static libs: Updated liblinebreak to libunibreak's latest version. diff --git a/src/lib/ecore_x/xcb/ecore_xcb_selection.c b/src/lib/ecore_x/xcb/ecore_xcb_selection.c index 6d5c5aca4c..1a5b539705 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_selection.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_selection.c @@ -449,7 +449,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, { Ecore_X_Selection_Intern *sel; Ecore_X_Selection_Converter *cnv; - void *data; + void *data = NULL; char *tgt_str; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -461,7 +461,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, { if (cnv->target == target) { - int r = 0; + int r; r = cnv->convert(tgt_str, sel->data, sel->length, &data, size, targtype, typesize); @@ -475,6 +475,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, return EINA_FALSE; } } + free(tgt_str); return EINA_FALSE; } diff --git a/src/lib/ecore_x/xlib/ecore_x_selection.c b/src/lib/ecore_x/xlib/ecore_x_selection.c index 8d38b60d3f..60cf2cf1a7 100644 --- a/src/lib/ecore_x/xlib/ecore_x_selection.c +++ b/src/lib/ecore_x/xlib/ecore_x_selection.c @@ -545,7 +545,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, { Ecore_X_Selection_Intern *sel; Ecore_X_Selection_Converter *cnv; - void *data; + void *data = NULL; char *tgt_str; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -569,6 +569,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, return EINA_FALSE; } } + free(tgt_str); /* ICCCM says "If the selection cannot be converted into a form based on the target (and parameters, if any), the owner should refuse the SelectionRequest as previously described." */ return EINA_FALSE;