File 0001-Fix-use-of-uninitialized-var-leak-.-Fix-1786.patch of Package ecore

From e1147ea2d714bda14695bdf3075ff47e059ee9ee Mon Sep 17 00:00:00 2001
From: billiob <billiob@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Date: Sun, 13 Jan 2013 14:08:34 +0000
Subject: [PATCH] Fix use of uninitialized var + leak--. Fix #1786

git-svn-id: http://svn.enlightenment.org/svn/e/branches/ecore-1.7@82729 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
---
 ChangeLog                                 |    6 ++++++
 src/lib/ecore_x/xcb/ecore_xcb_selection.c |    5 +++--
 src/lib/ecore_x/xlib/ecore_x_selection.c  |    4 +++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a8a5985..6cfc909 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1050,3 +1050,9 @@
 2013-01-04  Luis Felipe Strano Moraes
 
 	* 1.7.5 release
+
+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.
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_selection.c b/src/lib/ecore_x/xcb/ecore_xcb_selection.c
index 92f4f3d..5496f89 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_selection.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_selection.c
@@ -486,7 +486,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__);
@@ -498,7 +498,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);
@@ -512,6 +512,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 5d71906..7d4e1fc 100644
--- a/src/lib/ecore_x/xlib/ecore_x_selection.c
+++ b/src/lib/ecore_x/xlib/ecore_x_selection.c
@@ -569,7 +569,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__);
@@ -581,6 +581,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection,
         if (cnv->target == target)
           {
              int r;
+
              r = cnv->convert(tgt_str, sel->data, sel->length, &data, size,
                               targtype, typesize);
              free(tgt_str);
@@ -593,6 +594,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;
-- 
1.7.10.4

openSUSE Build Service is sponsored by