Make a new memory arena for Tuple::clear

To avoid potential problem of invalidating contents of previously returned from
pack() calls.
This commit is contained in:
Jingyu Zhou 2022-09-15 12:49:11 -07:00
parent b19f1b5e3b
commit a4f9ef8aaa
1 changed files with 3 additions and 1 deletions

View File

@ -71,7 +71,9 @@ struct Tuple {
size_t size() const { return offsets.size(); }
void reserve(size_t cap) { offsets.reserve(cap); }
void clear() {
data.clear();
// Make a new Standalone to use different memory so that
// previously returned objects from pack() are valid.
data = Standalone<VectorRef<uint8_t>>();
offsets.clear();
}
// Return a Tuple encoded raw string.