From 23e26b558562d3695d98a765c916fd7eec6ef3bb Mon Sep 17 00:00:00 2001 From: Northn Date: Fri, 4 Jun 2021 13:58:01 +0400 Subject: [PATCH] Solve undefined behavior in VMT hooker destructor --- src/libs/rtdhook/rtdhook.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/rtdhook/rtdhook.hpp b/src/libs/rtdhook/rtdhook.hpp index 03e157a..81e098c 100644 --- a/src/libs/rtdhook/rtdhook.hpp +++ b/src/libs/rtdhook/rtdhook.hpp @@ -134,9 +134,10 @@ class rtdhook_vmt { */ ~rtdhook_vmt() { - for (auto& method : mHookedList) + for (auto ptr = mHookedList.begin(); ptr < mHookedList.end();) { - uninstall(method.id); + rewrite_pointer(ptr->id, ptr->original); + ptr = mHookedList.erase(ptr); } }