[sr-dev] git:master:2d40e14d: presence_xml: better error handling to free all allocated vars

Daniel-Constantin Mierla miconda at gmail.com
Thu May 14 13:53:02 CEST 2015


Module: kamailio
Branch: master
Commit: 2d40e14d2b0b150acd34ac2d1df25936d8faaca9
URL: https://github.com/kamailio/kamailio/commit/2d40e14d2b0b150acd34ac2d1df25936d8faaca9

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-05-14T13:15:06+02:00

presence_xml: better error handling to free all allocated vars

---

Modified: modules/presence_xml/pres_check.c

---

Diff:  https://github.com/kamailio/kamailio/commit/2d40e14d2b0b150acd34ac2d1df25936d8faaca9.diff
Patch: https://github.com/kamailio/kamailio/commit/2d40e14d2b0b150acd34ac2d1df25936d8faaca9.patch

---

diff --git a/modules/presence_xml/pres_check.c b/modules/presence_xml/pres_check.c
index 4504048..8f45c0f 100644
--- a/modules/presence_xml/pres_check.c
+++ b/modules/presence_xml/pres_check.c
@@ -140,7 +140,7 @@ int presxml_check_activities(struct sip_msg *msg, str presentity_uri, str activi
 	if (presentity == NULL || presentity->len <= 0 || presentity->s == NULL)
 	{
 		LM_DBG("cannot get presentity for %.*s\n", presentity_uri.len, presentity_uri.s);
-		return -1;
+		goto error;
 	}
 
 	if ((xmlDoc = xmlParseMemory(presentity->s, presentity->len)) == NULL)
@@ -192,6 +192,7 @@ int presxml_check_activities(struct sip_msg *msg, str presentity_uri, str activi
 		pkg_free(nodeName);
 	if (xmlDoc != NULL)
 		xmlFreeDoc(xmlDoc);
-	pres_free_presentity(presentity, ev);
+	if(presentity != NULL)
+		pres_free_presentity(presentity, ev);
 	return retval;
 }




More information about the sr-dev mailing list