diff --git a/include/support/jni_util.h b/include/support/jni_util.h index 7bfd897844..54ef526684 100644 --- a/include/support/jni_util.h +++ b/include/support/jni_util.h @@ -115,6 +115,9 @@ class JStringRef { llvm::errs() << "JStringRef was passed a null pointer at \n" << GetJavaStackTrace(env); } + // Ensure str is null-terminated. + m_str.push_back('\0'); + m_str.pop_back(); } operator llvm::StringRef() const { return m_str; }