Browse code

presence_xml: better error handling to free all allocated vars

(cherry picked from commit 2d40e14d2b0b150acd34ac2d1df25936d8faaca9)

Daniel-Constantin Mierla authored on 14/05/2015 11:15:06
Showing 1 changed files
... ...
@@ -140,7 +140,7 @@ int presxml_check_activities(struct sip_msg *msg, str presentity_uri, str activi
140 140
 	if (presentity == NULL || presentity->len <= 0 || presentity->s == NULL)
141 141
 	{
142 142
 		LM_DBG("cannot get presentity for %.*s\n", presentity_uri.len, presentity_uri.s);
143
-		return -1;
143
+		goto error;
144 144
 	}
145 145
 
146 146
 	if ((xmlDoc = xmlParseMemory(presentity->s, presentity->len)) == NULL)
... ...
@@ -192,6 +192,7 @@ error:
192 192
 		pkg_free(nodeName);
193 193
 	if (xmlDoc != NULL)
194 194
 		xmlFreeDoc(xmlDoc);
195
-	pres_free_presentity(presentity, ev);
195
+	if(presentity != NULL)
196
+		pres_free_presentity(presentity, ev);
196 197
 	return retval;
197 198
 }