libutils: disallow extending lifetime on stack

Bug: 232557259
Test: libutils_test
Change-Id: Iacf45b9f295a48904606ced35994ba35566bfcc3
This commit is contained in:
Steven Moreland 2022-07-26 22:11:13 +00:00
parent c340a08b1b
commit d086fe5109

View file

@ -791,6 +791,8 @@ RefBase::~RefBase()
void RefBase::extendObjectLifetime(int32_t mode)
{
check_not_on_stack(this);
// Must be happens-before ordered with respect to construction or any
// operation that could destroy the object.
mRefs->mFlags.fetch_or(mode, std::memory_order_relaxed);