Browse code

- fixed a memory leak when dealing with authorization ( reported by Adrian Georgescu )

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2283 689a6050-402a-0410-94f2-e92a70836424

Anca Vamanu authored on 24/05/2007 13:03:17
Showing 4 changed files
... ...
@@ -38,7 +38,7 @@
38 38
 
39 39
 struct subscription;
40 40
 
41
-typedef int (apply_auth_t)(str* , struct subscription*, str* );
41
+typedef int (apply_auth_t)(str* , struct subscription*, str** );
42 42
 
43 43
 typedef int (publ_handling_t)(struct sip_msg*);
44 44
 
... ...
@@ -1139,6 +1139,7 @@ int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body)
1139 1139
 	db_key_t db_keys[1], update_keys[4];
1140 1140
 	db_val_t db_vals[1], update_vals[4];
1141 1141
     c_back_param *cb_param= NULL;
1142
+	str* final_body= NULL;
1142 1143
 	
1143 1144
 	DBG("PRESENCE:notify:dialog informations:\n");
1144 1145
 	printf_subs(subs);
... ...
@@ -1154,7 +1155,7 @@ int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body)
1154 1155
 	{
1155 1156
 		if( subs->event->req_auth)
1156 1157
 		{	
1157
-			if( subs->event->apply_auth_nbody(n_body, subs, notify_body)< 0)
1158
+			if( subs->event->apply_auth_nbody(n_body, subs, &notify_body)< 0)
1158 1159
 			{
1159 1160
 				LOG(L_ERR, "PRESENCE:notify: ERROR in function hget_nbody\n");
1160 1161
 				goto error;
... ...
@@ -1196,9 +1197,8 @@ int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body)
1196 1197
 				else		/* apply authorization rules if exists */
1197 1198
 				if(subs->event->req_auth)
1198 1199
 				{
1199
-					str* final_body= NULL;
1200 1200
 					 
1201
-					if(subs->event->apply_auth_nbody(notify_body, subs, final_body)< 0)
1201
+					if(subs->event->apply_auth_nbody(notify_body, subs, &final_body)< 0)
1202 1202
 					{
1203 1203
 						LOG(L_ERR, "PRESENCE:notify: ERROR in function apply_auth\n");
1204 1204
 						goto error;
... ...
@@ -65,17 +65,19 @@ str* pres_agg_nbody(str** body_array, int n, int off_index)
65 65
 		xmlFree(body_array[off_index]->s);
66 66
 		pkg_free(body_array[off_index]);
67 67
 	}
68
+	xmlCleanupParser();
69
+    xmlMemoryDump();
68 70
 
69 71
 	return n_body;
70 72
 }	
71 73
 
72
-int pres_apply_auth(str* notify_body, subs_t* subs, str* final_nbody)
74
+int pres_apply_auth(str* notify_body, subs_t* subs, str** final_nbody)
73 75
 {
74 76
 	xmlDocPtr doc= NULL;
75 77
 	xmlNodePtr node= NULL;
76 78
 	str* n_body= NULL;
77 79
 	
78
-	final_nbody= NULL;
80
+	*final_nbody= NULL;
79 81
 	if(force_active)
80 82
 		return 0;
81 83
 
... ...
@@ -105,7 +107,10 @@ int pres_apply_auth(str* notify_body, subs_t* subs, str* final_nbody)
105 107
 	}
106 108
 
107 109
 	xmlFreeDoc(doc);
108
-	final_nbody= n_body;
110
+	xmlCleanupParser();
111
+    xmlMemoryDump();
112
+
113
+	*final_nbody= n_body;
109 114
 	return 1;
110 115
 
111 116
 }	
... ...
@@ -400,14 +405,12 @@ str* get_final_notify_body( subs_t *subs, str* notify_body, xmlNodePtr rule_node
400 405
 
401 406
     xmlFreeDoc(doc);
402 407
 
403
-    xmlCleanupParser();
404
-
405
-    xmlMemoryDump();
406
-
407 408
 	xmlFree(class_cont);
408 409
 	xmlFree(occurence_ID);
409 410
 	xmlFree(deviceID);
410 411
 	xmlFree(service_uri);
412
+    xmlCleanupParser();
413
+    xmlMemoryDump();
411 414
 
412 415
     return new_body;
413 416
 error:
... ...
@@ -30,6 +30,6 @@
30 30
 #define _NBODY_H_
31 31
 
32 32
 str* pres_agg_nbody(str** body_array, int n, int off_index);
33
-int pres_apply_auth(str* notify_body, subs_t* subs, str* final_nbody);
33
+int pres_apply_auth(str* notify_body, subs_t* subs, str** final_nbody);
34 34
 
35 35
 #endif