From 0b559106bf1b0d193a734be0f0e5ba099240aa6a Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 23 Sep 2008 19:07:13 +0000 Subject: [PATCH] * Only copy over the list content if resizing/allocating the list succeded. Fixes CID 1268. * Remove no more correct comment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27710 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/List.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kits/support/List.cpp b/src/kits/support/List.cpp index a758fac2dc..80334f82db 100644 --- a/src/kits/support/List.cpp +++ b/src/kits/support/List.cpp @@ -83,9 +83,11 @@ BList& BList::operator =(const BList &list) { fBlockSize = list.fBlockSize; - _ResizeArray(list.fItemCount); - fItemCount = list.fItemCount; - memcpy(fObjectList, list.fObjectList, fItemCount * sizeof(void*)); + if (_ResizeArray(list.fItemCount)) { + fItemCount = list.fItemCount; + memcpy(fObjectList, list.fObjectList, fItemCount * sizeof(void*)); + } + return *this; } @@ -451,7 +453,6 @@ void BList::_ReservedList2() {} // Resize // // Resizes fObjectList to be large enough to contain count items. -// fItemCount is adjusted accordingly. bool BList::_ResizeArray(int32 count) {