summaryrefslogtreecommitdiff
path: root/msm8084
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2016-04-06 23:45:35 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-04-06 23:45:35 +0000
commite8489978d2e92144422bf19208a02aca7948514d (patch)
tree72915cf74cfea24edb2ea183137fa0e12d4a941e /msm8084
parentae527def6fe1e8036a88942f0f9f27cbbaf9e736 (diff)
parenta31fdb90c079353fa78920ef13a29fac0c427446 (diff)
downloadgps-e8489978d2e92144422bf19208a02aca7948514d.tar.gz
Fix memory leak in loc_update_conf().
am: a31fdb9 * commit 'a31fdb90c079353fa78920ef13a29fac0c427446': Fix memory leak in loc_update_conf(). Change-Id: Iebe3c10aca8848ed2caca2ed265924a28951571a
Diffstat (limited to 'msm8084')
-rw-r--r--msm8084/utils/loc_cfg.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/msm8084/utils/loc_cfg.cpp b/msm8084/utils/loc_cfg.cpp
index 7030121..104cdd7 100644
--- a/msm8084/utils/loc_cfg.cpp
+++ b/msm8084/utils/loc_cfg.cpp
@@ -329,20 +329,26 @@ int loc_update_conf(const char* conf_data, int32_t length,
if (conf_data && length && config_table && table_length) {
// make a copy, so we do not tokenize the original data
char* conf_copy = (char*)malloc(length+1);
- 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;
-
- 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);
+
+ if (conf_copy != NULL)
+ {
+ 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;
+
+ 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);
}
}