dlech / KeeAgent

ssh agent plugin for KeePass 2.x
http://lechnology.com/software/keeagent
Other
530 stars 35 forks source link

Crash when opening the Group menu #304

Closed thespooler closed 4 years ago

thespooler commented 4 years ago

Description

When no database is open, or when the open database is locked, opening the Group menu crashes KeePass.

Steps to reproduce

  1. Open KeePass
  2. Close the Open Database dialog (ESC or Cancel)
  3. Click on Group menu

Result

Unhandled exception dialog box.

Expected result

Group menu with disabled items.

Exception stacktrace

System.NullReferenceException: Object reference not set to an instance of an object.
   at KeeAgent.KeeAgentExt.UpdateGroupMenuItem(ToolStripMenuItem groupMenuItem)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripDropDownItem.OnDropDownShow(EventArgs e)
   at System.Windows.Forms.ToolStripDropDownItem.ShowDropDownInternal()
   at System.Windows.Forms.ToolStripMenuItem.OnMouseButtonStateChange(MouseEventArgs e, Boolean isMouseDown)
   at System.Windows.Forms.ToolStripItem.HandleMouseDown(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseDown(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.MenuStrip.WndProc(Message& m)
   at KeePass.UI.CustomMenuStripEx.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
dlech commented 4 years ago

What versions of KeeAgent and KeePass are you using?

thespooler commented 4 years ago

KeeAgent 0.12.0 KeePass 2.45

thespooler commented 4 years ago

In KeeAgentExt.cs, line 472

var recycleBin = activeDatabase.RootGroup.FindGroup(activeDatabase.RecycleBinUuid, true);

See PwGroup class, property RootGroup:

        // Summary:
        //     Get the root group that contains all groups and entries stored in the database.
        //
        // Returns:
        //     Root group. The return value is null, if no database has been opened.

Also, MainWindow.GetSelectedGroup() can be null if none is selected.

thespooler commented 4 years ago

Would you like me to whip up a PR?