From f02798b9f833469869c2642ce73f8d660c9c8ddf Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 22 Jan 2018 17:55:17 -0800 Subject: [PATCH] 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 --- core/jni/android_database_SQLiteCommon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/jni/android_database_SQLiteCommon.cpp b/core/jni/android_database_SQLiteCommon.cpp index 34544d37a6bfd..daa20876ba654 100644 --- a/core/jni/android_database_SQLiteCommon.cpp +++ b/core/jni/android_database_SQLiteCommon.cpp @@ -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);