From d96e89cd9c9e43224be56a734285ec716525df07 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Tue, 26 May 2020 05:42:36 -0700 Subject: [PATCH] btif_config: Fix pointer to freed memory We change the scope of our 'string' declaration so the contents are still in scope when we use a pointer to them. Previously, the contents were out of scope when we referenced them through a pointer. Bug: 148758680 Test: TreeHugger Change-Id: Ib0aa689bf4547d079b77965d958cc382ba0276e6 --- btif/src/btif_config.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btif/src/btif_config.cc b/btif/src/btif_config.cc index b39564caf..d2250a789 100644 --- a/btif/src/btif_config.cc +++ b/btif/src/btif_config.cc @@ -517,11 +517,11 @@ bool btif_config_get_bin(const std::string& section, const std::string& key, bool in_encrypt_key_name_list = btif_in_encrypt_key_name_list(key); bool is_key_encrypted = *value_str_from_config == ENCRYPTED_STR; + std::string string; if (!value_str_from_config->empty() && in_encrypt_key_name_list && is_key_encrypted) { - std::string string = - get_bluetooth_keystore_interface()->get_key(section + "-" + key); + string = get_bluetooth_keystore_interface()->get_key(section + "-" + key); value_str = &string; } else { value_str = value_str_from_config; -- 2.11.0