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 <[email protected]> --- src/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menu.c b/src/menu.c index 8322dbb..83eb804 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; } -- 2.1.4 -- To unsubscribe, send mail to [email protected].
