[NFC][sanitizer] Early return for empty StackTraces

Current callers should filter them out anyway,
but with this patch we don't need rely on that assumption.
This commit is contained in:
Vitaly Buka 2021-11-23 12:51:12 -08:00
parent cdc80a6017
commit b80affb8a1

View file

@ -17,6 +17,8 @@ namespace __sanitizer {
static constexpr u32 kStackSizeBits = 16;
StackStore::Id StackStore::Store(const StackTrace &trace) {
if (!trace.size && !trace.tag)
return 0;
uptr *stack_trace = Alloc(trace.size + 1);
CHECK_LT(trace.size, 1 << kStackSizeBits);
*stack_trace = trace.size + (trace.tag << kStackSizeBits);
@ -25,6 +27,8 @@ StackStore::Id StackStore::Store(const StackTrace &trace) {
}
StackTrace StackStore::Load(Id id) {
if (!id)
return {};
const uptr *stack_trace = reinterpret_cast<const uptr *>(id);
uptr size = *stack_trace & ((1 << kStackSizeBits) - 1);
uptr tag = *stack_trace >> kStackSizeBits;