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

Commit ddbf6c70 authored by Dimitry Ivanov's avatar Dimitry Ivanov
Browse files

Use modified android_dlwarning

The new form of android_dlwarning is thread-safe
and does not have a problem with dlwarning returning
a pointer that can in some situations become invalid.

Bug: http://b/27453994
Change-Id: Ied8366439467a9afd783a3b22b8c48b8709ac9aa
parent 3be2727d
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -15,16 +15,25 @@
 */

#include <poll.h>
#include <android/dlext.h>

#include <string>

#include "core_jni_helpers.h"

extern "C" void android_dlwarning(void*, void (*)(void*, const char*));

namespace android
{

static jstring getDlWarning_native(JNIEnv* env, jobject) {
    const char* text = android_dlwarning();
    return text == nullptr ? nullptr : env->NewStringUTF(text);
    std::string msg;
    android_dlwarning(&msg, [](void* obj, const char* msg) {
        if (msg != nullptr) {
            *reinterpret_cast<std::string*>(obj) = msg;
        }
    });

    return msg.empty() ? nullptr : env->NewStringUTF(msg.c_str());
}

static const JNINativeMethod g_methods[] = {