瀏覽代碼

rls: free resources in case of errors

Daniel-Constantin Mierla 3 年之前
父節點
當前提交
72443722d7
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      src/modules/rls/resource_notify.c

+ 6 - 6
src/modules/rls/resource_notify.c

@@ -146,6 +146,9 @@ int send_notify(xmlDocPtr * rlmi_doc, char * buf, int buf_len,
 	int result = 0;
 	str rlmi_cont= {0, 0}, multi_cont;
 
+	if(rlmi_doc==NULL || *rlmi_doc==NULL) {
+		return -1;
+	}
 	xmlDocDumpFormatMemory(*rlmi_doc,(xmlChar**)(void*)&rlmi_cont.s,
 			&rlmi_cont.len, 0);
 
@@ -183,7 +186,6 @@ static void send_notifies(db1_res_t *result, int did_col, int resource_uri_col,
 	subs_t* dialog= NULL;
 	int len_est = 0;
 	int resource_added = 0; /* Flag to indicate that we have added at least one resource */
-	int ok = 0;
 
 	/* generate the boundary string */
 	boundary_string= generate_string(BOUNDARY_STRING_LEN);
@@ -431,7 +433,6 @@ static void send_notifies(db1_res_t *result, int did_col, int resource_uri_col,
 	}
 
 done:
-	ok = 1;
 	if (dbmode == RLS_DB_ONLY && rls_dbf.end_transaction)
 	{
 		if (rls_dbf.end_transaction(rls_db) < 0)
@@ -456,11 +457,10 @@ error:
 			LM_ERR("in abort_transaction\n");
 	}
 
-	if(ok==0) {
-		if(rlmi_doc!=NULL) {
-			xmlFreeDoc(rlmi_doc);
-		}
+	if(rlmi_doc!=NULL) {
+		xmlFreeDoc(rlmi_doc);
 	}
+
 	return;
 }