From c743be7560affd67849a7aea20f664797f9ead5a Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Thu, 16 Oct 2025 13:15:24 +0800 Subject: [PATCH] fix: sync with qt5platform-plugins https://github.com/linuxdeepin/qt5platform-plugins/pull/305 --- 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 aed8a9ad..01dd0ac0 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)