Commit c7440fe8 authored by Kenton Varda's avatar Kenton Varda Committed by GitHub

Merge pull request #578 from capnproto/revert-549-nullish-array-builder

Revert "avoid passing invalid reference to Array<T> constructor"
parents d067d620 9842ff91
......@@ -450,17 +450,11 @@ public:
// check might catch bugs. Probably people should use Vector if they want to build arrays
// without knowing the final size in advance.
KJ_IREQUIRE(pos == endPtr, "ArrayBuilder::finish() called prematurely.");
const ptrdiff_t size = pos - ptr;
T* start = reinterpret_cast<T*>(ptr);
Array<T> result(reinterpret_cast<T*>(ptr), pos - ptr, *disposer);
ptr = nullptr;
pos = nullptr;
endPtr = nullptr;
if (size == 0) {
// `disposer` possibly does not point to anything, so don't pass `*disposer` to `Array`.
return Array<T>();
} else {
return Array<T>(start, size, *disposer);
}
return result;
}
inline bool isFull() const {
......
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