Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcin-matula-2329518
Copy link
Contributor

No description provided.

@@ -111,7 +111,9 @@ int main(int argc, const char *argv[])

if ((node = exec(line, strlen(line), NULL)) != NULL) {
if ((obj = (cJSON *)network_tree_to_json(node)) != NULL) {
printf("%s\n", cJSON_Print(obj));
char* tmp = cJSON_Print(obj);
printf("%s\n", tmp);
Copy link
Contributor Author

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.

snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",cJSON_Print(parent_obj));
char* tmp = cJSON_Print(parent_obj);
snprintf(subdoc->buff,sizeof(em_subdoc_data_buff_t),"%s",tmp);
cJSON_free(tmp);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to reproduce the issue again:
https://jira.rdkcentral.com/jira/browse/RDKBWIFI-17?focusedId=457298&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-457298

Engineer with higher experience in cJSON should give opinion if we can process this diff. I would like avoid double-free situation

Copy link
Contributor Author

@marcin-matula-2329518 marcin-matula-2329518 Jan 9, 2025

Choose a reason for hiding this comment

The 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.

@soumyasmunshi
Copy link
Contributor

soumyasmunshi commented Jan 9, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants