Skip to content

Commit ae785f1

Browse files
SessionHero01SessionHero01
andauthored
Fix an incorrect usage of NewStringUTF (#14)
Co-authored-by: SessionHero01 <[email protected]>
1 parent 55caa0f commit ae785f1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/src/main/cpp/logging.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ Java_network_loki_messenger_libsession_1util_util_Logger_00024Companion_addLogge
3131
return; // Failed to attach thread, cannot log
3232
}
3333

34+
// Java strings need null-terminated C strings, we'll have to copy them here unfortunately
35+
std::string msg_str(msg);
36+
std::string category_str(category);
37+
3438
env->CallVoidMethod(loggerRef, logMethod,
35-
JavaLocalRef(env, env->NewStringUTF(msg.data())).get(),
36-
JavaLocalRef(env, env->NewStringUTF(category.data())).get(),
39+
JavaLocalRef(env, env->NewStringUTF(msg_str.c_str())).get(),
40+
JavaLocalRef(env, env->NewStringUTF(category_str.c_str())).get(),
3741
static_cast<jint>(level.level)
3842
);
3943
});

0 commit comments

Comments
 (0)