-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDKBWIFI-17 Fixes for lack of cJSON_free for cJSON_Print output #117
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,7 +353,10 @@ int dm_easy_mesh_t::encode_config_reset(em_subdoc_info_t *subdoc, const char *ke | |
|
||
formatted_json = cJSON_Print(parent_obj); | ||
printf("%s:%d: %s\n", __func__, __LINE__, formatted_json); | ||
snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",cJSON_Print(parent_obj)); | ||
cJSON_free(formatted_json); | ||
char* tmp = cJSON_Print(parent_obj); | ||
snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",tmp); | ||
cJSON_free(tmp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not able to reproduce the issue again: Engineer with higher experience in cJSON should give opinion if we can process this diff. I would like avoid double-free situation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @soumyasmunshi let me know what do you think about that pull request. It seems evident that we have problem with memory leaks in unified-wifi-mesh due to cJSON_Print. I would like to avoid push this changes before your presentation for your bosses to avoid double-free-corruption (in the case if it is freed already). All these memory leaks were detected by AddressSanitizer but I keep only one callstack: https://jira.rdkcentral.com/jira/browse/RDKBWIFI-17?focusedId=457298&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-457298 I think that this change can needed more tests (at least reproduce the issue). I will keep it as draft. |
||
cJSON_Delete(parent_obj); | ||
return 0; | ||
} | ||
|
@@ -608,7 +611,10 @@ int dm_easy_mesh_t::encode_config_test(em_subdoc_info_t *subdoc, const char *key | |
|
||
formatted_json = cJSON_Print(parent_obj); | ||
printf("%s:%d: %s\n", __func__, __LINE__, formatted_json); | ||
snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",cJSON_Print(parent_obj)); | ||
cJSON_free(formatted_json); | ||
char* tmp = cJSON_Print(parent_obj); | ||
snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",tmp); | ||
cJSON_free(tmp); | ||
cJSON_Delete(parent_obj); | ||
return 0; | ||
} | ||
|
@@ -1888,6 +1894,7 @@ void dm_easy_mesh_t::create_autoconfig_renew_json_cmd(char* src_mac_addr, char* | |
cJSON_AddItemToObject(root, "wfa-dataelements:Renew", renew); | ||
char* tmp = cJSON_Print(root); | ||
snprintf(autoconfig_renew_json, sizeof(autoconfig_renew_json), "%s", tmp); | ||
cJSON_free(tmp); | ||
cJSON_Delete(root); | ||
} | ||
|
||
|
@@ -1909,6 +1916,7 @@ void dm_easy_mesh_t::create_ap_cap_query_json_cmd(char* src_mac_addr, char* agen | |
cJSON_AddItemToObject(root, "wfa-dataelements:Radiocap", query_info); | ||
char* tmp = cJSON_Print(root); | ||
snprintf(ap_query_json, sizeof(ap_query_json), "%s", tmp); | ||
cJSON_free(tmp); | ||
cJSON_Delete(root); | ||
} | ||
|
||
|
@@ -1931,6 +1939,7 @@ void dm_easy_mesh_t::create_client_cap_query_json_cmd(char* src_mac_addr, char* | |
cJSON_AddItemToObject(root, "wfa-dataelements:Clientcap", query_info); | ||
char* tmp = cJSON_Print(root); | ||
snprintf(ap_query_json, sizeof(ap_query_json), "%s", tmp); | ||
cJSON_free(tmp); | ||
cJSON_Delete(root); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is cli which will be deprecated.