diff options
| -rw-r--r-- | runtime/jni/java_vm_ext.cc | 9 | ||||
| -rw-r--r-- | runtime/ti/agent.cc | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc index 7a9d292dd3..6d4ceb5065 100644 --- a/runtime/jni/java_vm_ext.cc +++ b/runtime/jni/java_vm_ext.cc @@ -87,9 +87,10 @@ class SharedLibrary { self->GetJniEnv()->DeleteWeakGlobalRef(class_loader_); } - std::string error_msg; + char* error_msg = nullptr; if (!android::CloseNativeLibrary(handle_, needs_native_bridge_, &error_msg)) { LOG(WARNING) << "Error while unloading native library \"" << path_ << "\": " << error_msg; + android::NativeLoaderFreeErrorMessage(error_msg); } } @@ -962,17 +963,19 @@ bool JavaVMExt::LoadNativeLibrary(JNIEnv* env, Locks::mutator_lock_->AssertNotHeld(self); const char* path_str = path.empty() ? nullptr : path.c_str(); bool needs_native_bridge = false; + char* nativeloader_error_msg; void* handle = android::OpenNativeLibrary(env, runtime_->GetTargetSdkVersion(), path_str, class_loader, library_path.get(), &needs_native_bridge, - error_msg); - + &nativeloader_error_msg); VLOG(jni) << "[Call to dlopen(\"" << path << "\", RTLD_NOW) returned " << handle << "]"; if (handle == nullptr) { + *error_msg = nativeloader_error_msg; + free(nativeloader_error_msg); VLOG(jni) << "dlopen(\"" << path << "\", RTLD_NOW) failed: " << *error_msg; return false; } diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc index 033c8acc39..0202fbc872 100644 --- a/runtime/ti/agent.cc +++ b/runtime/ti/agent.cc @@ -118,7 +118,7 @@ std::unique_ptr<Agent> AgentSpec::DoDlOpen(JNIEnv* env, : JavaVMExt::GetLibrarySearchPath(env, class_loader)); bool needs_native_bridge = false; - std::string nativeloader_error_msg; + char* nativeloader_error_msg = nullptr; void* dlopen_handle = android::OpenNativeLibrary(env, Runtime::Current()->GetTargetSdkVersion(), name_.c_str(), @@ -129,7 +129,8 @@ std::unique_ptr<Agent> AgentSpec::DoDlOpen(JNIEnv* env, if (dlopen_handle == nullptr) { *error_msg = StringPrintf("Unable to dlopen %s: %s", name_.c_str(), - nativeloader_error_msg.c_str()); + nativeloader_error_msg); + android::NativeLoaderFreeErrorMessage(nativeloader_error_msg); *error = kLoadingError; return nullptr; } @@ -137,7 +138,7 @@ std::unique_ptr<Agent> AgentSpec::DoDlOpen(JNIEnv* env, // TODO: Consider support? // The result of this call and error_msg is ignored because the most // relevant error is that native bridge is unsupported. - android::CloseNativeLibrary(dlopen_handle, needs_native_bridge, error_msg); + android::CloseNativeLibrary(dlopen_handle, needs_native_bridge, &nativeloader_error_msg); *error_msg = StringPrintf("Native-bridge agents unsupported: %s", name_.c_str()); *error = kLoadingError; return nullptr; |