Module: sip-router
Branch: alexh/master
Commit: 01ced1d37b003e1509dd671d09f825f4c9e94220
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=01ced1d…
Author: Alex Hermann <alex(a)speakup.nl>
Committer: Alex Hermann <alex(a)speakup.nl>
Date: Thu Mar 24 18:50:23 2011 +0100
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.
---
xavp.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/xavp.c b/xavp.c
index 622c058..aac6d21 100644
--- a/xavp.c
+++ b/xavp.c
@@ -136,7 +136,7 @@ sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val,
sr_xavp_t **list)
&& strncmp(avp->name.s, name->s, name->len)==0)
{
if(idx==n)
- return avp;
+ break;
n++;
}
prv = avp;
@@ -166,16 +166,13 @@ sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val,
sr_xavp_t **list)
avp->val.v.s.s[val->v.s.len] = '\0';
avp->val.v.s.len = val->v.s.len;
}
- if(prv)
- {
- avp->next = prv->next;
- prv->next = avp;
+ avp->next = tmp->next;
+ if(prv) {
+ prv->next = avp;
} else {
if(list) {
- avp->next = *list;
*list = avp;
} else {
- avp->next = *_xavp_list_crt;
*_xavp_list_crt = avp;
}
}