diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-25 17:49:56 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-25 17:49:56 -0400 |
| commit | 2ce82eea5c7d5e05a3e3d220c19bbdac830e7dba (patch) | |
| tree | d9b448134b8f63743e0c70eb74c71ac899a59caa /pkfuncinstr.h | |
| parent | 7c7b8dd41be35ec1c540356e039ef3692fc07732 (diff) | |
pkmem: handle overflows & leaks in tests
Diffstat (limited to 'pkfuncinstr.h')
| -rw-r--r-- | pkfuncinstr.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pkfuncinstr.h b/pkfuncinstr.h index 0f76eed..3a30bd3 100644 --- a/pkfuncinstr.h +++ b/pkfuncinstr.h @@ -90,11 +90,11 @@ void pk_funcinstr_init() { __attribute__((no_instrument_function)) void pk_funcinstr_teardown() { - size_t i, k; + int64_t i, k; mtx_lock(&thrd_mstr.mtx); - for (i = 0; i < thrd_mstr.n_buckets; ++i) { + for (i = ((int64_t)thrd_mstr.n_buckets)-1; i > -1; --i) { struct pk_funcinstr_bkt *bkt = thrd_mstr.buckets[i]; - for (k = 0; k < bkt->used_count; ++k) { + for (k = ((int64_t)bkt->used_count)-1; k > -1; --k) { free(bkt->data[k].children); } } @@ -140,6 +140,7 @@ void pk_funcinstr_detect_and_handle_reset() { should_hard_reset = should_hard_reset || (thrd_mstr.reset_time.tv_sec == pk_funcinstr_thrd_bkt->reset_time.tv_sec && thrd_mstr.reset_time.tv_nsec > pk_funcinstr_thrd_bkt->reset_time.tv_nsec); } if (should_hard_reset) { + if (pk_funcinstr_thrd_bkt != NULL) free(pk_funcinstr_thrd_bkt); pk_funcinstr_thrd_bkt = NULL; pk_funcinstr_thrd_instr = NULL; should_reset = true; |
