From e3f99a4a2200c40391d014729d91f9f0dd64b49b Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 26 Dec 2016 14:13:15 -0800 Subject: [PATCH] JStringRef: ensure string is null terminated so c_str() works correctly. --- include/support/jni_util.h | 3 +++ 1 file changed, 3 insertions(+) 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; }