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.
develop
lethosor 2016-03-22 17:27:53 -04:00
parent ede81c0f09
commit b8bbf5f545
1 changed files with 7 additions and 2 deletions

@ -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,...)