From cb3243fbbd1f06f5c205c7cbc3a6911586d6cf9e Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 12 Jun 2014 18:26:52 -0400 Subject: [PATCH] shortcut_catcher: Fix KeyCommandMap::_DeleteHKSList() You can't increment the list item counter as you delete because the count decreases as you go. Instead delete the first item until there are no more items, then delete the list. --- .../shortcut_catcher/KeyCommandMap.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp b/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp index f1302a2cb7..268dca92b6 100644 --- a/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp +++ b/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp @@ -1,9 +1,10 @@ /* - * Copyright 1999-2009 Haiku Inc. All rights reserved. + * Copyright 1999-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Jeremy Friesner + * John Scipione, jscipione@gmail.com */ @@ -323,16 +324,17 @@ KeyCommandMap::MessageReceived(BMessage* msg) } -//! Deletes an HKS-filled BList and its contents. +// deletes the BList and its contents void -KeyCommandMap::_DeleteHKSList(BList* l) +KeyCommandMap::_DeleteHKSList(BList* list) { - if (l != NULL) { - int num = l->CountItems(); - for (int i = 0; i < num; i++) - delete ((hks*) l->ItemAt(i)); - delete l; - } + if (list == NULL) + return; + + while (list->ItemAt(0) != NULL) + delete list->ItemAt(0); + + delete list; }