Browse code

modules_k/siputils: Fix memory leak in uri_param() function

Richard Fuchs authored on 07/11/2012 14:12:33
Showing 1 changed files
... ...
@@ -168,7 +168,7 @@ int uri_param_2(struct sip_msg* _msg, char* _param, char* _value)
168 168
 	str *param, *value, t;
169 169
 
170 170
 	param_hooks_t hooks;
171
-	param_t* params;
171
+	param_t* params, *pit;
172 172
 
173 173
 	param = (str*)_param;
174 174
 	value = (str*)_value;
... ...
@@ -185,25 +185,23 @@ int uri_param_2(struct sip_msg* _msg, char* _param, char* _value)
185 185
 	        return -1;
186 186
 	}
187 187
 
188
-	while (params) {
189
-		if ((params->name.len == param->len) &&
190
-		    (strncmp(params->name.s, param->s, param->len) == 0)) {
188
+	for (pit = params; pit; pit = pit->next) {
189
+		if ((pit->name.len == param->len) &&
190
+		    (strncmp(pit->name.s, param->s, param->len) == 0)) {
191 191
 			if (value) {
192
-				if ((value->len == params->body.len) &&
193
-				    strncmp(value->s, params->body.s, value->len) == 0) {
192
+				if ((value->len == pit->body.len) &&
193
+				    strncmp(value->s, pit->body.s, value->len) == 0) {
194 194
 					goto ok;
195 195
 				} else {
196 196
 					goto nok;
197 197
 				}
198 198
 			} else {
199
-				if (params->body.len > 0) {
199
+				if (pit->body.len > 0) {
200 200
 					goto nok;
201 201
 				} else {
202 202
 					goto ok;
203 203
 				}
204 204
 			}
205
-		} else {
206
-			params = params->next;
207 205
 		}
208 206
 	}
209 207