Commit 110ed1c9 authored by Sylvain Berfini's avatar Sylvain Berfini

Fix crash when receiving some UTF-8 chars

parent 13bacf87
......@@ -2726,11 +2726,15 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_store(JNIEnv* en
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env
extern "C" jbyteArray Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env
,jobject thiz
,jlong ptr) {
jstring jvalue =env->NewStringUTF(linphone_chat_message_get_text((LinphoneChatMessage*)ptr));
return jvalue;
const char *message = linphone_chat_message_get_text((LinphoneChatMessage*)ptr);
size_t length = strlen(message);
jbyteArray array = env->NewByteArray(length);
env->SetByteArrayRegion(array, 0, length, (const jbyte*)message);
return array;
extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getReason(JNIEnv* env
package org.linphone.core;
public class LinphoneChatMessageImpl implements LinphoneChatMessage {
protected final long nativePtr;
private native String getText(long ptr);
private native byte[] getText(long ptr);
private native long getPeerAddress(long ptr);
private native String getExternalBodyUrl(long ptr);
private native void setExternalBodyUrl(long ptr, String url);
......@@ -25,7 +27,12 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
public String getText() {
return getText(nativePtr);
try {
return new String(getText(nativePtr), "UTF-8");
} catch (UnsupportedEncodingException e) {
return null;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment