Browse code

core/xavps: Fix assignment to indexed subname.

$xavp(name1[idx1]=>name2[idx2])

When idx2 is used, the current value is now replaced instead of ignored.

Alex Hermann authored on 24/03/2011 17:50:23
Showing 1 changed files
... ...
@@ -136,7 +136,7 @@ sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list)
136 136
 				&& strncmp(avp->name.s, name->s, name->len)==0)
137 137
 		{
138 138
 			if(idx==n)
139
-				return avp;
139
+				break;
140 140
 			n++;
141 141
 		}
142 142
 		prv = avp;
... ...
@@ -166,16 +166,13 @@ sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list)
166 166
 		avp->val.v.s.s[val->v.s.len] = '\0';
167 167
 		avp->val.v.s.len = val->v.s.len;
168 168
 	}
169
-	if(prv)
170
-	{
171
-			avp->next = prv->next;
172
-			prv->next = avp;
169
+	avp->next = tmp->next;
170
+	if(prv) {
171
+		prv->next = avp;
173 172
 	} else {
174 173
 		if(list) {
175
-			avp->next = *list;
176 174
 			*list = avp;
177 175
 		} else {
178
-			avp->next = *_xavp_list_crt;
179 176
 			*_xavp_list_crt = avp;
180 177
 		}
181 178
 	}