Frameworks: Fix scoping problem in SQLite

Fix the scope of a std::string to avoid a use-after-free.

Test: m && SANITIZE_TARGET=address m
Change-Id: I4b4c299b4ab2c82d76489cc68a398f33b6220e32
This commit is contained in:
Andreas Gampe
2018-01-22 17:55:17 -08:00
parent be982d72fe
commit f02798b9f8

View File

@@ -223,8 +223,8 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode,
if (sqlite3Message) {
String8 fullMessage;
fullMessage.append(sqlite3Message);
const char* errcode_msg = sqlite3_error_code_to_msg(errcode).c_str();
fullMessage.appendFormat(" (code %s)", errcode_msg); // print extended error code
std::string errcode_msg = sqlite3_error_code_to_msg(errcode);
fullMessage.appendFormat(" (code %s)", errcode_msg.c_str()); // print extended error code
if (message) {
fullMessage.append(": ");
fullMessage.append(message);