summaryrefslogtreecommitdiff
path: root/osi
diff options
context:
space:
mode:
authorMarie Janssen <jamuraa@google.com>2016-04-05 11:36:15 -0700
committerMarie Janssen <jamuraa@google.com>2016-04-05 17:16:21 -0700
commitda576af1312568c4892e6b217d89a82897d60d91 (patch)
tree46e2152b657473e41abd5806306a6da6b5267d87 /osi
parentb9d28c30f9ef9f8f046bb08238abef9cba445be6 (diff)
downloadandroid-system-bt-da576af1312568c4892e6b217d89a82897d60d91.tar.gz
android-system-bt-da576af1312568c4892e6b217d89a82897d60d91.tar.xz
Fix memory leak when saving paired devices
Followup from r.android.com/210955 Minor style fixes for osi/config also included. Bug: 26071376 Change-Id: I26563b75a59a6f0ae074676754889cb988a69358
Diffstat (limited to 'osi')
-rw-r--r--osi/include/config.h3
-rw-r--r--osi/src/config.c2
-rw-r--r--osi/test/config_test.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/osi/include/config.h b/osi/include/config.h
index 3d7630f..d7c8ff9 100644
--- a/osi/include/config.h
+++ b/osi/include/config.h
@@ -43,7 +43,8 @@ config_t *config_new(const char *filename);
//
// |src| must not be NULL
// This function will not return NULL.
-config_t *config_clone(config_t *src);
+// Clients must call config_free on the returned object.
+config_t *config_new_clone(const config_t *src);
// Frees resources associated with the config file. No further operations may
// be performed on the |config| object after calling this function. |config|
diff --git a/osi/src/config.c b/osi/src/config.c
index 8157bd5..6c76ae1 100644
--- a/osi/src/config.c
+++ b/osi/src/config.c
@@ -94,7 +94,7 @@ config_t *config_new(const char *filename) {
return config;
}
-config_t *config_clone(config_t *src) {
+config_t *config_new_clone(const config_t *src) {
assert(src != NULL);
config_t *ret = config_new_empty();
diff --git a/osi/test/config_test.cpp b/osi/test/config_test.cpp
index 2b61db1..0fb2fe1 100644
--- a/osi/test/config_test.cpp
+++ b/osi/test/config_test.cpp
@@ -80,9 +80,9 @@ TEST_F(ConfigTest, config_free_null) {
config_free(NULL);
}
-TEST_F(ConfigTest, config_clone) {
+TEST_F(ConfigTest, config_new_clone) {
config_t *config = config_new(CONFIG_FILE);
- config_t *clone = config_clone(config);
+ config_t *clone = config_new_clone(config);
config_set_string(clone, CONFIG_DEFAULT_SECTION, "first_key", "not_value");