Module: kamailio
Branch: master
Commit: 1e4bf1dd7fbfc9d51f0e56e98472a42de781cdbd
URL:
https://github.com/kamailio/kamailio/commit/1e4bf1dd7fbfc9d51f0e56e98472a42…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-08-16T09:09:45+02:00
msrp: proper cmap insert when last item has greater citemid
- condition for last item was processed first, resulting in improper
order of items, GH #3215
---
Modified: src/modules/msrp/msrp_cmap.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1e4bf1dd7fbfc9d51f0e56e98472a42…
Patch:
https://github.com/kamailio/kamailio/commit/1e4bf1dd7fbfc9d51f0e56e98472a42…
---
diff --git a/src/modules/msrp/msrp_cmap.c b/src/modules/msrp/msrp_cmap.c
index 9764c0903f5..2fc6a8d740b 100644
--- a/src/modules/msrp/msrp_cmap.c
+++ b/src/modules/msrp/msrp_cmap.c
@@ -270,20 +270,21 @@ int msrp_cmap_save(msrp_frame_t *mf)
} else {
for(itb=_msrp_cmap_head->cslots[idx].first; itb; itb=itb->next)
{
- if(itb->citemid>it->citemid || itb->next==NULL) {
- if(itb->next==NULL) {
- itb->next=it;
- it->prev = itb;
+ if(itb->citemid>it->citemid) {
+ /* insert before current item */
+ it->next = itb;
+ if(itb->prev==NULL) {
+ _msrp_cmap_head->cslots[idx].first = it;
} else {
- it->next = itb;
- if(itb->prev==NULL) {
- _msrp_cmap_head->cslots[idx].first = it;
- } else {
- itb->prev->next = it;
- }
- it->prev = itb->prev;
- itb->prev = it;
+ itb->prev->next = it;
}
+ it->prev = itb->prev;
+ itb->prev = it;
+ break;
+ } else if(itb->next==NULL) {
+ /* insert after last item */
+ itb->next=it;
+ it->prev = itb;
break;
}
}