Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d12f7a4 authored by Michael Wright's avatar Michael Wright
Browse files

Make the log message in setInteractive a local variable.

If the error message isn't a local variable, it will go out of scope
immediately after LogIfSlow is constructed. Unfortunately, LogIfSlow
maintains a pointer to String8s internal char* member... which causes a
use after free when it goes to log. Oops.

Bug: 62820330
Test: none
Change-Id: Ie1da3be723f8aae165822002ff42954480a43aa5
parent 592e85b4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -157,8 +157,10 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring
static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
    std::lock_guard<std::mutex> lock(gPowerHalMutex);
    if (getPowerHal()) {
        String8 err("Excessive delay in setInteractive(%s) while turning screen %s");
        ALOGD_IF_SLOW(20, String8::format(err, enable ? "true" : "false", enable ? "on" : "off"));
        String8 err = String8::format(
                "Excessive delay in setInteractive(%s) while turning screen %s",
                enable ? "true" : "false", enable ? "on" : "off");
        ALOGD_IF_SLOW(20, err);
        Return<void> ret = gPowerHal->setInteractive(enable);
        processReturn(ret, "setInteractive");
    }