mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 14:08:06 +01:00
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 <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
15db368291
commit
ae07899122
@@ -312,10 +312,10 @@ void wMenuEntrySetCascade(WMenu * menu, WMenuEntry * entry, WMenu * cascade)
|
|||||||
if (!done) {
|
if (!done) {
|
||||||
entry->cascade = menu->cascade_no;
|
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;
|
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;
|
brother->cascades[brother->cascade_no++] = cascade->brother;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user