Don't use destroyed values in SkArenaAllocWithReset

Found with `MSAN_OPTIONS=poison_in_dtor=1`. Avoid using fields after
`this` has been destroyed.

Change-Id: I3a772ca053c03520268a7e0328402365b5592c40
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528438
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2022-04-07 12:20:42 -04:00 committed by SkCQ
parent f3bf819705
commit 43ac2e3740

View File

@ -144,8 +144,11 @@ SkArenaAllocWithReset::SkArenaAllocWithReset(char* block,
, fFirstHeapAllocationSize{SkToU32(firstHeapAllocation)} {}
void SkArenaAllocWithReset::reset() {
char* const firstBlock = fFirstBlock;
const uint32_t firstSize = fFirstSize;
const uint32_t firstHeapAllocationSize = fFirstHeapAllocationSize;
this->~SkArenaAllocWithReset();
new (this) SkArenaAllocWithReset{fFirstBlock, fFirstSize, fFirstHeapAllocationSize};
new (this) SkArenaAllocWithReset{firstBlock, firstSize, firstHeapAllocationSize};
}
// SkFibonacci47 is the first 47 Fibonacci numbers. Fib(47) is the largest value less than 2 ^ 32.