[haiku-commits] haiku: hrev46522 - src/apps/haiku-depot

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 10 Dec 2013 23:08:06 +0100 (CET)

hrev46522 adds 1 changeset to branch 'master'
old head: 55ef89adc2d55429c0962cf1b4790a876cfde30d
new head: 96c5f7eda4aac78b5787a89666d4d4fa5190dd66
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=96c5f7e+%5E55ef89a

----------------------------------------------------------------------------

96c5f7e: HaikuDepot: Fixed some inconsistencies in List.h

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46522
Commit:      96c5f7eda4aac78b5787a89666d4d4fa5190dd66
URL:         http://cgit.haiku-os.org/haiku/commit/?id=96c5f7e
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Dec 10 22:07:16 2013 UTC

----------------------------------------------------------------------------

1 file changed, 5 insertions(+), 5 deletions(-)
src/apps/haiku-depot/List.h | 10 +++++-----

----------------------------------------------------------------------------

diff --git a/src/apps/haiku-depot/List.h b/src/apps/haiku-depot/List.h
index 52ac431..03d1a96 100644
--- a/src/apps/haiku-depot/List.h
+++ b/src/apps/haiku-depot/List.h
@@ -120,10 +120,8 @@ public:
 
        inline bool Add(const ItemType& copyFrom, int32 index)
        {
-               if (index < 0)
-                       index = 0;
-               if (index > (int32)fCount)
-                       index = fCount;
+               if (index < 0 || index >= (int32)fCount)
+                       return false;
 
                if (!_Resize(fCount + 1))
                        return false;
@@ -190,7 +188,7 @@ public:
 
        inline const ItemType& ItemAt(int32 index) const
        {
-               if (index >= (int32)fCount)
+               if (index < 0 || index >= (int32)fCount)
                        return fNullItem;
                return ItemAtFast(index);
        }
@@ -202,6 +200,8 @@ public:
 
        inline const ItemType& LastItem() const
        {
+               if (fCount == 0)
+                       return fNullItem;
                return ItemAt((int32)fCount - 1);
        }
 


Other related posts:

  • » [haiku-commits] haiku: hrev46522 - src/apps/haiku-depot - superstippi