Module: kamailio Branch: 5.5 Commit: f97b189d238bd63f80a4525c56501cd394b7d2f3 URL: https://github.com/kamailio/kamailio/commit/f97b189d238bd63f80a4525c56501cd3...
Author: Wolfgang Kampichler dev@kampichler.info Committer: Wolfgang Kampichler dev@kampichler.info Date: 2021-04-30T12:26:53+02:00
lost: fixed possible resource leak inside lost_get_response_issues()
(cherry picked from commit a1bbe035f1a1acc11f86d27fdc0adef1b1a3d010)
---
Modified: src/modules/lost/response.c
---
Diff: https://github.com/kamailio/kamailio/commit/f97b189d238bd63f80a4525c56501cd3... Patch: https://github.com/kamailio/kamailio/commit/f97b189d238bd63f80a4525c56501cd3...
---
diff --git a/src/modules/lost/response.c b/src/modules/lost/response.c index b3389448b8..6eb13e8260 100644 --- a/src/modules/lost/response.c +++ b/src/modules/lost/response.c @@ -573,39 +573,53 @@ p_lost_issue_t lost_get_response_issues(xmlNodePtr node) cur = node->children; while(cur) { if(cur->type == XML_ELEMENT_NODE) { - /* get a new response type element */ + /* get a new response type object */ issue = lost_new_response_type(); if(issue == NULL) { /* didn't get it ... return */ break; } - /* parse properties */ - issue->source = lost_get_property(cur->parent, MAPP_PROP_SRC, &len); + /* get issue type */ tmp.s = (char *)cur->name; tmp.len = strlen((char *)cur->name); + /* copy issue type to object */ + len = 0; if(tmp.len > 0 && tmp.s != NULL) { issue->type = lost_copy_string(tmp, &len); } - if(len > 0) { + if(len == 0) { + /* issue type not found, clean up and return */ + lost_delete_response_type(&issue); /* clean up */ + break; + } + /* parse source property */ + len = 0; + issue->source = lost_get_property(cur->parent, MAPP_PROP_SRC, &len); + if(len == 0) { + /* source property not found, clean up and return */ + lost_delete_response_type(&issue); /* clean up */ + break; + }
- LM_DBG("###\t[%s]\n", issue->type); + LM_DBG("###\t[%s]\n", issue->type);
- if(issue->info != NULL) { - issue->info->text = lost_get_property(cur, PROP_MSG, &len); - issue->info->lang = lost_get_property(cur, PROP_LANG, &len); - } - /* get a new list element */ - new = lost_new_response_issues(); - if(new == NULL) { - /* didn't get it, delete response type element ... return */ - lost_delete_response_type(&issue); /* clean up */ - break; - } - /* append to list */ - new->issue = issue; - new->next = list; - list = new; + /* type and source property found ... parse text and copy */ + if(issue->info != NULL) { + issue->info->text = lost_get_property(cur, PROP_MSG, &len); + issue->info->lang = lost_get_property(cur, PROP_LANG, &len); } + /* get a new list element */ + new = lost_new_response_issues(); + if(new == NULL) { + /* didn't get it, clean up and return */ + lost_delete_response_type(&issue); /* clean up */ + break; + } + /* parsing done, append object to list */ + new->issue = issue; + new->next = list; + list = new; + /* get next element */ cur = cur->next; }