From b2bdc199cb6aec64034e672f7590aa2a7a27194c Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 26 Aug 2012 22:43:18 +0400 Subject: [PATCH] Fix NULL pointer access in ~virtual_identity. --- library/DataDefs.cpp | 6 ++++-- library/VTableInterpose.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp index 4428a2f76..341164441 100644 --- a/library/DataDefs.cpp +++ b/library/DataDefs.cpp @@ -218,8 +218,10 @@ virtual_identity::virtual_identity(size_t size, TAllocateFn alloc, virtual_identity::~virtual_identity() { // Remove interpose entries, so that they don't try accessing this object later - while (!interpose_list.empty()) - interpose_list.begin()->second->on_host_delete(this); + for (auto it = interpose_list.begin(); it != interpose_list.end(); ++it) + if (it->second) + it->second->on_host_delete(this); + interpose_list.clear(); } /* Vtable name to identity lookup. */ diff --git a/library/VTableInterpose.cpp b/library/VTableInterpose.cpp index 47110cece..04c436ba7 100644 --- a/library/VTableInterpose.cpp +++ b/library/VTableInterpose.cpp @@ -311,7 +311,7 @@ void VMethodInterposeLinkBase::on_host_delete(virtual_identity *from) // Unlink the chains child_hosts.erase(from); - from->interpose_list.erase(vmethod_idx); + from->interpose_list[vmethod_idx] = NULL; } }