From 160b71644dfdf8efd1f19cdf8e9f572fe1b86d9d Mon Sep 17 00:00:00 2001 From: d4rkk3y <43563783+d4rkk3y@users.noreply.github.com> Date: Sat, 18 Feb 2023 15:26:51 +0700 Subject: [PATCH] fix(tiktok/show-seekbar): fix crash when showing seekbar (#1643) --- .../seekbar/patch/ShowSeekbarPatch.kt | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt index 0c99ab370..31d6d1289 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.tiktok.interaction.seekbar.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -14,6 +15,7 @@ import app.revanced.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCo import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.AwemeGetVideoControlFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction11n +import org.jf.dexlib2.builder.instruction.BuilderInstruction21t import org.jf.dexlib2.builder.instruction.BuilderInstruction22c @Patch @@ -32,15 +34,18 @@ class ShowSeekbarPatch : BytecodePatch( ?: return PatchResultError("Can not find target class") val fieldList = videoControl.immutableClass.fields.associateBy { field -> field.name } - val method = AwemeGetVideoControlFingerprint.result!!.mutableMethod - val implementation = method.implementation!! - implementation.addInstructions( - 1, listOf( - BuilderInstruction11n(Opcode.CONST_4, 1, 1), - BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["showProgressBar"]!!), - BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["draftProgressBar"]!!) + AwemeGetVideoControlFingerprint.result?.mutableMethod?.implementation?.apply { + val ifNullLabel = newLabelForIndex(1) + addInstructions( + 1, + listOf( + BuilderInstruction11n(Opcode.CONST_4, 1, 1), + BuilderInstruction21t(Opcode.IF_EQZ, 0, ifNullLabel), + BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["showProgressBar"]!!), + BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["draftProgressBar"]!!) + ) ) - ) + } ?: return AwemeGetVideoControlFingerprint.toErrorResult() return PatchResultSuccess() }