devilhorns pushed a commit to branch master.

commit 2a1b9931621644477cb2d193d24a2776d1e1999a
Author: Chris Michael <[email protected]>
Date:   Mon Jul 8 09:00:45 2013 +0100

    Fix "Allocation size mismatch" reported by Coverity (short version: we
    declared our 'roots' variable as Ecore_X_Window, but were allocating
    as 'Window').
    
    buffer_alloc: "malloc(num * 8UL)" allocates memory.
    CID 1039601: Allocation size mismatch (SIZECHECK)
    5. incorrect_multiplication: Allocating a multiple of 8 bytes to
    pointer of type Ecore_X_Window, which needs 4 bytes.
    
    NB: Fixes Coverity CID1039601
    
    Signed-off-by: Chris Michael <[email protected]>
---
 src/lib/ecore_x/xlib/ecore_x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/lib/ecore_x/xlib/ecore_x.c b/src/lib/ecore_x/xlib/ecore_x.c
index f15ca25..92a796a 100644
--- a/src/lib/ecore_x/xlib/ecore_x.c
+++ b/src/lib/ecore_x/xlib/ecore_x.c
@@ -1189,7 +1189,7 @@ ecore_x_window_root_list(int *num_ret)
                          overlap++;
                     }
                }
-             roots = malloc(MAX((num - overlap) * sizeof(Window), 1));
+             roots = malloc(MAX((num - overlap) * sizeof(Ecore_X_Window), 1));
              if (roots)
                {
                   int k;
@@ -1221,7 +1221,7 @@ ecore_x_window_root_list(int *num_ret)
           }
         else
           {
-             roots = malloc(num * sizeof(Window));
+             roots = malloc(num * sizeof(Ecore_X_Window));
              if (!roots)
                return NULL;
 
@@ -1232,7 +1232,7 @@ ecore_x_window_root_list(int *num_ret)
      }
    else
      {
-        roots = malloc(num * sizeof(Window));
+        roots = malloc(num * sizeof(Ecore_X_Window));
         if (!roots)
           return NULL;
 
@@ -1243,7 +1243,7 @@ ecore_x_window_root_list(int *num_ret)
 
 #else /* ifdef ECORE_XPRINT */
    num = ScreenCount(_ecore_x_disp);
-   roots = malloc(num * sizeof(Window));
+   roots = malloc(num * sizeof(Ecore_X_Window));
    if (!roots)
      return NULL;
 

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to