Commit e2744f24 authored by Harris Hancock's avatar Harris Hancock

Array<T>::attach() should copy size

parent 9cfe92c6
......@@ -447,6 +447,7 @@ TEST(Array, AttachNested) {
Array<Own<DestructionOrderRecorder>> combined = arr.attach(kj::mv(obj2)).attach(kj::mv(obj3));
KJ_EXPECT(combined.begin() == ptr);
KJ_EXPECT(combined.size() == 1);
KJ_EXPECT(obj1.get() == nullptr);
KJ_EXPECT(obj2.get() == nullptr);
......
......@@ -862,6 +862,7 @@ template <typename T>
template <typename... Attachments>
Array<T> Array<T>::attach(Attachments&&... attachments) {
T* ptrCopy = ptr;
auto sizeCopy = size_;
KJ_IREQUIRE(ptrCopy != nullptr, "cannot attach to null pointer");
......@@ -872,7 +873,7 @@ Array<T> Array<T>::attach(Attachments&&... attachments) {
auto bundle = new _::ArrayDisposableOwnedBundle<Array<T>, Attachments...>(
kj::mv(*this), kj::fwd<Attachments>(attachments)...);
return Array<T>(ptrCopy, size_, *bundle);
return Array<T>(ptrCopy, sizeCopy, *bundle);
}
template <typename T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment