From b8bbf5f54525ef1a611063395e02604e0df4965b Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 22 Mar 2016 17:27:53 -0400 Subject: [PATCH] field_offset: Use actual type instances instead of reinterpret_cast(type, 1) ui_build_selector is a virtual class as of 0.42.06, so reinterpret_cast-ing it with bad addresses will crash. 'df.new(df.ui_build_selector)' works just fine. --- library/lua/memscan.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/lua/memscan.lua b/library/lua/memscan.lua index 00a80cc48..afee78aee 100644 --- a/library/lua/memscan.lua +++ b/library/lua/memscan.lua @@ -296,9 +296,14 @@ function field_ref(handle,...) end function field_offset(type,...) - local handle = df.reinterpret_cast(type,1) + local handle = df.new(type) + local _,haddr = df.sizeof(handle) local _,addr = df.sizeof(field_ref(handle,...)) - return addr-1 + -- to aid in diagnosis of bad virtual dtors + io.stderr:write('memscan: deleting instance of '..tostring(type) .. '\n'):flush() + df.delete(handle) + io.stderr:write('successfully deleted\n'):flush() + return addr-haddr end function MemoryArea:object_by_field(addr,type,...)