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

Commit e5e186c

Browse files
authored
ref: close handle only if active (#234)
* ref: close handle only if active * ref: run lint * ref: run lint
1 parent 7076bb1 commit e5e186c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bindings/cpu_profiler.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ class MeasurementsTicker {
108108

109109
~MeasurementsTicker() {
110110
uv_timer_stop(&timer);
111-
uv_close(reinterpret_cast<uv_handle_t *>(&timer), nullptr);
111+
112+
auto handle = reinterpret_cast<uv_handle_t *>(&timer);
113+
114+
// Calling uv_close on an inactive handle will cause a segfault.
115+
if (uv_is_active(handle)) {
116+
uv_close(handle, nullptr);
117+
}
112118
}
113119
};
114120

0 commit comments

Comments
 (0)