Fix Memory leak in util/loc_cfg.cpp
deallocate conf_copy after usage. Change-Id: I8ad4e4e8007a2d8b608f3f74503515f062b86c4b CRs-fixed: 852809
This commit is contained in:
parent
9eb36c357a
commit
634c1bb8bd
1 changed files with 16 additions and 15 deletions
|
@ -330,12 +330,11 @@ 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;
|
||||
}
|
||||
|
||||
// start with one record off
|
||||
uint32_t num_params = table_length - 1;
|
||||
|
@ -349,6 +348,8 @@ int loc_update_conf(const char* conf_data, int32_t length,
|
|||
num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
|
||||
input_buf = strtok_r(NULL, "\n", &saveptr);
|
||||
}
|
||||
free(conf_copy);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue