Fix prof_tdata_get()-related regressions.
Fix prof_tdata_get() to avoid dereferencing an invalid tdata pointer
(when it's PROF_TDATA_STATE_{REINCARNATED,PURGATORY}).
Fix prof_tdata_get() callers to check for invalid results besides NULL
(PROF_TDATA_STATE_{REINCARNATED,PURGATORY}).
These regressions were caused by
602c8e0971
(Implement per thread heap
profiling.), which did not make it into any releases prior to these
fixes.
This commit is contained in:
@@ -308,12 +308,13 @@ prof_tdata_get(bool create)
|
||||
|
||||
tdata = *prof_tdata_tsd_get();
|
||||
if (create) {
|
||||
if (tdata == NULL)
|
||||
tdata = prof_tdata_init();
|
||||
else if (tdata->state == prof_tdata_state_expired)
|
||||
if ((uintptr_t)tdata <= (uintptr_t)PROF_TDATA_STATE_MAX) {
|
||||
if (tdata == NULL)
|
||||
tdata = prof_tdata_init();
|
||||
} else if (tdata->state == prof_tdata_state_expired)
|
||||
tdata = prof_tdata_reinit(tdata);
|
||||
assert(tdata == NULL || tdata->state ==
|
||||
prof_tdata_state_attached);
|
||||
assert((uintptr_t)tdata <= (uintptr_t)PROF_TDATA_STATE_MAX ||
|
||||
tdata->state == prof_tdata_state_attached);
|
||||
}
|
||||
|
||||
return (tdata);
|
||||
|
Reference in New Issue
Block a user