summaryrefslogtreecommitdiff
path: root/utils/loc_cfg.cpp
diff options
context:
space:
mode:
authorQaing Chen <chenq@codeaurora.org>2015-06-11 16:52:05 -0700
committerQiang Chen <chenq@codeaurora.org>2015-06-11 17:51:35 -0700
commit634c1bb8bda7a3e953962cbff0343046b74a861f (patch)
treeaaa032a78adf1c3d24126c40a3a915410a95ab8a /utils/loc_cfg.cpp
parent9eb36c357ab9e71807c86e86d9713dc471a83cab (diff)
downloadgps-634c1bb8bda7a3e953962cbff0343046b74a861f.tar.gz
Fix Memory leak in util/loc_cfg.cpp
deallocate conf_copy after usage. Change-Id: I8ad4e4e8007a2d8b608f3f74503515f062b86c4b CRs-fixed: 852809
Diffstat (limited to 'utils/loc_cfg.cpp')
-rw-r--r--utils/loc_cfg.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp
index 7ffe6a4..a769776 100644
--- a/utils/loc_cfg.cpp
+++ b/utils/loc_cfg.cpp
@@ -330,24 +330,25 @@ int loc_update_conf(const char* conf_data, int32_t length,
// make a copy, so we do not tokenize the original data
char* conf_copy = (char*)malloc(length+1);
- if(conf_copy !=NULL)
+ if (conf_copy != NULL)
{
- memcpy(conf_copy, conf_data, length);
- // we hard NULL the end of string to be safe
- conf_copy[length] = 0;
- }
+ memcpy(conf_copy, conf_data, length);
+ // we hard NULL the end of string to be safe
+ conf_copy[length] = 0;
+
+ // start with one record off
+ uint32_t num_params = table_length - 1;
+ char* saveptr = NULL;
+ char* input_buf = strtok_r(conf_copy, "\n", &saveptr);
+ ret = 0;
- // start with one record off
- uint32_t num_params = table_length - 1;
- char* saveptr = NULL;
- char* input_buf = strtok_r(conf_copy, "\n", &saveptr);
- ret = 0;
-
- LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
- while(num_params && input_buf) {
- ret++;
- num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
- input_buf = strtok_r(NULL, "\n", &saveptr);
+ LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
+ while(num_params && input_buf) {
+ ret++;
+ num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
+ input_buf = strtok_r(NULL, "\n", &saveptr);
+ }
+ free(conf_copy);
}
}