diff --git a/ecmascript/containers/containers_bitvector.cpp b/ecmascript/containers/containers_bitvector.cpp index ceb01dde30..3ea4606331 100644 --- a/ecmascript/containers/containers_bitvector.cpp +++ b/ecmascript/containers/containers_bitvector.cpp @@ -57,7 +57,7 @@ JSTaggedValue ContainersBitVector::BitVectorConstructor(EcmaRuntimeCallInfo* arg auto* newBitSetVector = new std::vector>(); if (!length->IsZero()) { - int32_t capacity = (length->GetInt() >> JSAPIBitVector::TAGGED_VALUE_BIT_SIZE) + 1; + int32_t capacity = (length->GetInt() / JSAPIBitVector::BIT_SET_LENGTH) + 1; std::bitset initBitSet; newBitSetVector->resize(capacity, initBitSet); diff --git a/ecmascript/js_api/js_api_bitvector.cpp b/ecmascript/js_api/js_api_bitvector.cpp index a7da7ba165..e5d96e399e 100644 --- a/ecmascript/js_api/js_api_bitvector.cpp +++ b/ecmascript/js_api/js_api_bitvector.cpp @@ -428,8 +428,8 @@ void JSAPIBitVector::Resize(JSThread* thread, const JSHandle& bi [[maybe_unused]] ConcurrentApiScope scope(thread, bitVector.GetTaggedValue().GetTaggedObject()); int length = bitVector->GetLength().GetInt(); - uint32_t elementsLength = ((length - 1) >> JSAPIBitVector::TAGGED_VALUE_BIT_SIZE) + 1; - uint32_t newElementsLength = ((newSize - 1) >> JSAPIBitVector::TAGGED_VALUE_BIT_SIZE) + 1; + uint32_t elementsLength = ((length - 1) / BIT_SET_LENGTH) + 1; + uint32_t newElementsLength = ((newSize - 1) / BIT_SET_LENGTH) + 1; JSHandle np(thread, bitVector->GetNativePointer()); auto elements = reinterpret_cast>*>(np->GetExternalPointer());