From 1bc1e6b9f115e58d5b4f52479d5e6da636530800 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Thu, 16 Oct 2025 05:17:40 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkcore Synchronize source files from linuxdeepin/dtkcore. Source-pull-request: https://github.com/linuxdeepin/dtkcore/pull/512 --- src/util/dvtablehook.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/util/dvtablehook.cpp b/src/util/dvtablehook.cpp index aed8a9a..01dd0ac 100644 --- a/src/util/dvtablehook.cpp +++ b/src/util/dvtablehook.cpp @@ -229,7 +229,21 @@ bool DVtableHook::hasVtable(const void *obj) { quintptr **_obj = (quintptr**)(obj); - return objToGhostVfptr.contains(_obj); + // 验证 vtable 是否匹配 + quintptr *ghost_vtable = objToGhostVfptr.value(obj); + if (!ghost_vtable) { + return false; + } + + // 检查当前对象的 vtable 指针是否指向我们记录的 ghost vtable + if (*_obj != adjustToEntry(ghost_vtable)) { + // vtable 不匹配,说明地址被重用了 + qCDebug(vtableHook) << "hasVtable: vtable mismatch! Address reused by different object." + << "obj:" << QString("0x%1").arg((quintptr)obj, 0, 16); + return false; + } + + return true; } void DVtableHook::resetVtable(const void *obj)