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 <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2013-07-08 09:00:45 +01:00
parent 9fb63c761f
commit 2a1b993162
1 changed files with 4 additions and 4 deletions

View File

@ -1189,7 +1189,7 @@ ecore_x_window_root_list(int *num_ret)
overlap++; overlap++;
} }
} }
roots = malloc(MAX((num - overlap) * sizeof(Window), 1)); roots = malloc(MAX((num - overlap) * sizeof(Ecore_X_Window), 1));
if (roots) if (roots)
{ {
int k; int k;
@ -1221,7 +1221,7 @@ ecore_x_window_root_list(int *num_ret)
} }
else else
{ {
roots = malloc(num * sizeof(Window)); roots = malloc(num * sizeof(Ecore_X_Window));
if (!roots) if (!roots)
return NULL; return NULL;
@ -1232,7 +1232,7 @@ ecore_x_window_root_list(int *num_ret)
} }
else else
{ {
roots = malloc(num * sizeof(Window)); roots = malloc(num * sizeof(Ecore_X_Window));
if (!roots) if (!roots)
return NULL; return NULL;
@ -1243,7 +1243,7 @@ ecore_x_window_root_list(int *num_ret)
#else /* ifdef ECORE_XPRINT */ #else /* ifdef ECORE_XPRINT */
num = ScreenCount(_ecore_x_disp); num = ScreenCount(_ecore_x_disp);
roots = malloc(num * sizeof(Window)); roots = malloc(num * sizeof(Ecore_X_Window));
if (!roots) if (!roots)
return NULL; return NULL;