From 400a0b774ed5ce1fca9eddaacfd378246308360c Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Mon, 3 Jun 2019 23:32:37 +0300 Subject: [PATCH] - Avoid possible crash when getting account's audio codecs. --- app/src/main/cpp/baresip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index 25164e07..593553e8 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -1236,6 +1236,8 @@ Java_com_tutpro_baresip_Api_call_1audio_1codecs(JNIEnv *env, jobject thiz, jstri if (len == -1) { LOGE("failed to get audio codecs of call %s\n", native_call); codec_buf[0] = '\0'; + } else { + codec_buf[len] = '\0'; } (*env)->ReleaseStringUTFChars(env, javaCall, native_call); return (*env)->NewStringUTF(env, codec_buf); @@ -1318,11 +1320,12 @@ Java_com_tutpro_baresip_Api_audio_1codecs(JNIEnv *env, jobject thiz) if (len == -1) { LOGE("failed to print codec to buffer\n"); codec_buf[0] = '\0'; - break; + return (*env)->NewStringUTF(env, codec_buf); } start = start + len; left = left - len; } + *start = '\0'; return (*env)->NewStringUTF(env, codec_buf); }