Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
ref: close handle only if active (#234)
Browse files Browse the repository at this point in the history
* ref: close handle only if active

* ref: run lint

* ref: run lint
  • Loading branch information
JonasBa authored Jan 11, 2024
1 parent 7076bb1 commit e5e186c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bindings/cpu_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ class MeasurementsTicker {

~MeasurementsTicker() {
uv_timer_stop(&timer);
uv_close(reinterpret_cast<uv_handle_t *>(&timer), nullptr);

auto handle = reinterpret_cast<uv_handle_t *>(&timer);

// Calling uv_close on an inactive handle will cause a segfault.
if (uv_is_active(handle)) {
uv_close(handle, nullptr);
}
}
};

Expand Down

0 comments on commit e5e186c

Please sign in to comment.