mirror of https://github.com/OpenVPN/openvpn-gui
				
				
				
			Fix crash when clicking on tray icon after importing the first profile
When clicking on tray icon, menu items are deleted and then recreated.
Deletion uses o.num_config:
    for (i = 0; i < o.num_configs; i++)
        DestroyMenu(hMenuConn[i]);
Commit 8e4183f9 ("Add '--command import' command line option")
added BuildFileList() call which modifies o.num_configs
but doesn't touch menus. When clicking on tray icon after import,
abovementioned code attemps to access invalid item in hMenuConn array
and crashes when this is the first imported profile and hMenuConn is NULL.
In other DestryMenu is called with invalid argument.
Fix by recreating popup menus instead of just rescan file list -
this will first delete menus with correct o.num_config value.
Signed-off-by: Lev Stipakov <lev@openvpn.net>
			
			
				pull/467/head
			
			
		
							parent
							
								
									77e32fa676
								
							
						
					
					
						commit
						a9f176224f
					
				
							
								
								
									
										4
									
								
								misc.c
								
								
								
								
							
							
						
						
									
										4
									
								
								misc.c
								
								
								
								
							|  | @ -704,6 +704,6 @@ ImportConfigFile(const TCHAR* source) | |||
|     } | ||||
| 
 | ||||
|     ShowTrayBalloon(LoadLocalizedString(IDS_NFO_IMPORT_SUCCESS), fileName); | ||||
|     /* rescan file list after import */ | ||||
|     BuildFileList(); | ||||
|     /* destroy popup menus, based on existing num_configs, rescan file list and recreate menus */ | ||||
|     RecreatePopupMenus(); | ||||
| } | ||||
|  |  | |||
							
								
								
									
										2
									
								
								tray.c
								
								
								
								
							
							
						
						
									
										2
									
								
								tray.c
								
								
								
								
							|  | @ -332,7 +332,7 @@ DestroyPopupMenus() | |||
| } | ||||
| 
 | ||||
| /* Rescan config folders and recreate popup menus */ | ||||
| static void | ||||
| void | ||||
| RecreatePopupMenus(void) | ||||
| { | ||||
|     DestroyPopupMenus(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Lev Stipakov
						Lev Stipakov