From 375bfe5e2183915752425ff65d3f0238db1b9e2d Mon Sep 17 00:00:00 2001 From: Vladimir Serykh Date: Fri, 29 Apr 2016 18:27:30 +0300 Subject: [PATCH] Fixed exception System.ArgumentOutOfRangeException: Index was out of range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When user being asked to allow or deny access to password, and user denies access – there will be no items in itemList and will be exception thrown. It was fixed. --- KeePassHttp/Handlers.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/KeePassHttp/Handlers.cs b/KeePassHttp/Handlers.cs index 0bceef9..7983483 100644 --- a/KeePassHttp/Handlers.cs +++ b/KeePassHttp/Handlers.cs @@ -350,7 +350,9 @@ private void GetLoginsHandler(Request r, Response resp, Aes aes) orderby e.entry.UsageCount ascending select e).ToList(); - ulong lowestDistance = itemsList[0].entry.UsageCount; + ulong lowestDistance = itemsList.Count > 0 ? + itemsList[0].entry.UsageCount : + 0; itemsList = (from e in itemsList where e.entry.UsageCount == lowestDistance