basehandle::type() in uv_walk which is in a timer callback causes double free (#213)

Close #212
This commit is contained in:
Stefano Fiorentino 2020-07-19 12:08:36 +02:00 committed by GitHub
parent 52785475b9
commit a10844d4bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,7 @@ enum class UVRunMode: std::underlying_type_t<uv_run_mode> {
* This can help to end all the pending requests by closing the handles.
*/
struct BaseHandle {
virtual ~BaseHandle() = default;
/**
* @brief Gets the category of the handle.
*

View File

@ -122,3 +122,17 @@ TEST(Timer, Fake) {
loop->run();
}
TEST(Timer, BaseHandleWalk) {
auto loop = uvw::Loop::getDefault();
auto timer = loop->resource<uvw::TimerHandle>();
timer->on<uvw::TimerEvent>([](const auto &event, uvw::TimerHandle &handle) {
auto &loop = handle.loop();
loop.walk([](uvw::BaseHandle& h){
h.type();
});
handle.close();
});
timer->start(uvw::TimerHandle::Time{1000}, uvw::TimerHandle::Time{1000});
loop->run();
}