mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-24 03:42:14 +03:00
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:
parent
7c17e1670d
commit
6fd53da030
2 changed files with 26 additions and 30 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue