Skip to content

Commit e29ec54

Browse files
authored
Correctly handle null thisObject in VectorChain for static methods (#658)
The previous implementation used a dummy `Any()` instance as a fallback when `thisObj` was null. This incorrectly bound an object instance to static method calls and prevented the terminal handler from receiving the required null pointer. We move core progression logic into a private `internalProceed` method that accepts a nullable `thisObject`. Moreover, we update libxposed submodule to include recent documentation changes (no API changes required).
1 parent ddcfa3d commit e29ec54

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

xposed/src/main/kotlin/org/matrix/vector/impl/hooks/VectorChain.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ class VectorChain(
4242

4343
override fun getArg(index: Int): Any? = args[index]
4444

45-
override fun proceed(): Any? = proceedWith(thisObj ?: Any(), args)
45+
override fun proceed(): Any? = internalProceed(thisObj, args)
4646

47-
override fun proceed(args: Array<Any?>): Any? = proceedWith(thisObj ?: Any(), args)
47+
override fun proceed(args: Array<Any?>): Any? = internalProceed(thisObj, args)
4848

49-
override fun proceedWith(thisObject: Any): Any? = proceedWith(thisObject, args)
49+
override fun proceedWith(thisObject: Any): Any? = internalProceed(thisObject, args)
5050

51-
override fun proceedWith(thisObject: Any, args: Array<Any?>): Any? {
51+
override fun proceedWith(thisObject: Any, args: Array<Any?>): Any? = internalProceed(thisObject, args)
52+
53+
private fun internalProceed(thisObject: Any?, currentArgs: Array<Any?>): Any? {
5254
proceedCalled = true
5355

5456
// Reached the end of the modern hooks; trigger the original executable (and legacy hooks)
@@ -86,7 +88,7 @@ class VectorChain(
8688
t: Throwable,
8789
record: VectorHookRecord,
8890
nextChain: VectorChain,
89-
recoveryThis: Any,
91+
recoveryThis: Any?,
9092
recoveryArgs: Array<Any?>,
9193
): Any? {
9294
// Check if the exception originated from downstream (lower hooks or original method)
@@ -103,7 +105,7 @@ class VectorChain(
103105
if (!nextChain.proceedCalled) {
104106
// Crash occurred before calling proceed(); skip hooker and continue the chain
105107
Utils.logD("Hooker [$hookerName] crashed before proceed. Skipping.", t)
106-
return nextChain.proceedWith(recoveryThis, recoveryArgs)
108+
return nextChain.internalProceed(recoveryThis, recoveryArgs)
107109
} else {
108110
// Crash occurred after calling proceed(); suppress and restore downstream state
109111
Utils.logD("Hooker [$hookerName] crashed after proceed. Restoring state.", t)

0 commit comments

Comments
 (0)