From ae078991221b32367f98754e632021d3975827aa Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 25 Apr 2015 12:44:23 +0200 Subject: [PATCH] wmaker: fix incorrect size for memory allocation (Coverity #50207) As pointed by Coverity, when increasing the size of the array allocated to store the pointers to menus in a cascaded menu, the incorrect value was used in argument to the sizeof which lead to over-allocating memory. This patch replaces the name of the structure (which should have been the pointer type) by the variable actually being used, fixing the size issue and making maintainability easier by tracking the type of the variable which is less prone to bugs in case of change. Signed-off-by: Christophe CURIS --- src/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menu.c b/src/menu.c index 8322dbb1..83eb8044 100644 --- a/src/menu.c +++ b/src/menu.c @@ -312,10 +312,10 @@ void wMenuEntrySetCascade(WMenu * menu, WMenuEntry * entry, WMenu * cascade) if (!done) { entry->cascade = menu->cascade_no; - menu->cascades = wrealloc(menu->cascades, sizeof(WMenu) * (menu->cascade_no + 1)); + menu->cascades = wrealloc(menu->cascades, sizeof(menu->cascades[0]) * (menu->cascade_no + 1)); menu->cascades[menu->cascade_no++] = cascade; - brother->cascades = wrealloc(brother->cascades, sizeof(WMenu) * (brother->cascade_no + 1)); + brother->cascades = wrealloc(brother->cascades, sizeof(brother->cascades[0]) * (brother->cascade_no + 1)); brother->cascades[brother->cascade_no++] = cascade->brother; }