Check menuobj before we dispose it

This commit is contained in:
Chris Young 2015-08-16 22:51:32 +01:00
parent b429a89ed6
commit 87ebe66880

View File

@ -517,19 +517,15 @@ void ami_free_menulabs(struct gui_window_2 *gwin)
{ {
int i; int i;
for(i=0;i<=AMI_MENU_AREXX_MAX;i++) for(i=0;i<=AMI_MENU_AREXX_MAX;i++) {
{ if(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL)) {
if(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL)) if(gwin->menutype[i] & MENU_IMAGE) {
{ if(gwin->menuobj[i]) DisposeObject(gwin->menuobj[i]);
if(gwin->menutype[i] & MENU_IMAGE)
{
DisposeObject(gwin->menuobj[i]);
} }
ami_utf8_free(gwin->menulab[i]); ami_utf8_free(gwin->menulab[i]);
if(i >= AMI_MENU_AREXX) if(i >= AMI_MENU_AREXX) {
{
if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data); if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data);
} }
} }
@ -888,7 +884,7 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i]; if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
gwin->menu[i].nm_Flags = 0; gwin->menu[i].nm_Flags = 0;
if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i]; if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
if(gwin->menuicon[i]) { if(gwin->menuicon[i]) {
free(gwin->menuicon[i]); free(gwin->menuicon[i]);
gwin->menuicon[i] = NULL; gwin->menuicon[i] = NULL;