Unconditionally poison RepeatedPtrField array after destruction.

Prior to RepeatedPtrField having an SOO, we did this for all sizes.  This
poisoning step can aid debugging for use-after-frees.

PiperOrigin-RevId: 572115487
pull/14301/head
Chris Kennelly 1 year ago committed by Copybara-Service
parent e80b8ec620
commit e032784c57
  1. 6
      src/google/protobuf/repeated_ptr_field.cc

@ -90,7 +90,6 @@ void RepeatedPtrFieldBase::DestroyProtos() {
ABSL_DCHECK(arena_ == nullptr);
if (using_sso()) {
delete static_cast<MessageLite*>(tagged_rep_or_elem_);
} else {
Rep* r = rep();
int n = r->allocated_size;
@ -100,8 +99,11 @@ void RepeatedPtrFieldBase::DestroyProtos() {
}
const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize;
internal::SizedDelete(r, size);
tagged_rep_or_elem_ = nullptr;
}
// TODO: Eliminate this store when invoked from the destructor,
// since it is dead.
tagged_rep_or_elem_ = nullptr;
}
void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) {

Loading…
Cancel
Save