Module: kamailio Branch: master Commit: 9f24f1109d6d491750c6feb19a9a6d0bcb674f90 URL: https://github.com/kamailio/kamailio/commit/9f24f1109d6d491750c6feb19a9a6d0b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-04-13T22:22:21+02:00
lost: simplify freeing local variables on error
- the helper function has conditions inside
---
Modified: src/modules/lost/functions.c
---
Diff: https://github.com/kamailio/kamailio/commit/9f24f1109d6d491750c6feb19a9a6d0b... Patch: https://github.com/kamailio/kamailio/commit/9f24f1109d6d491750c6feb19a9a6d0b...
---
diff --git a/src/modules/lost/functions.c b/src/modules/lost/functions.c index 5c653423144..278f5ea6906 100644 --- a/src/modules/lost/functions.c +++ b/src/modules/lost/functions.c @@ -784,12 +784,8 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf, xmlFreeDoc(doc); } /* clean up string */ - if(res.s != NULL && res.len > 0) { - lost_free_string(&res); - } - if(err.s != NULL && err.len > 0) { - lost_free_string(&err); - } + lost_free_string(&res); + lost_free_string(&err);
return LOST_CLIENT_ERROR; } @@ -1345,27 +1341,13 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, lost_free_geoheader_list(&geolist); lost_free_loc(&loc); /* clean up string */ - if(oldurl.s != NULL && oldurl.len > 0) { - lost_free_string(&oldurl); - } - if(ret.s != NULL && ret.len > 0) { - lost_free_string(&ret); - } - if(req.s != NULL && req.len > 0) { - lost_free_string(&req); - } - if(rereq.s != NULL && rereq.len > 0) { - lost_free_string(&rereq); - } - if(name.s != NULL && name.len > 0) { - lost_free_string(&name); - } - if(uri.s != NULL && uri.len > 0) { - lost_free_string(&uri); - } - if(err.s != NULL && err.len > 0) { - lost_free_string(&err); - } + lost_free_string(&oldurl); + lost_free_string(&ret); + lost_free_string(&req); + lost_free_string(&rereq); + lost_free_string(&name); + lost_free_string(&uri); + lost_free_string(&err);
return LOST_CLIENT_ERROR; }