tm: proper location of last rr for strict routing on local requests
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:24:22 +0000 (09:24 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:31:49 +0000 (09:31 +0200)
src/modules/tm/t_fwd.c
src/modules/tm/t_msgbuilder.c

index ac55e3a..df9eef4 100644 (file)
@@ -1190,7 +1190,7 @@ static struct cancel_reason* cancel_reason_pack(short cause, void* data,
                } else if (cause == CANCEL_REAS_PACKED_HDRS &&
                                !(t->flags & T_NO_E2E_CANCEL_REASON) && data) {
                        txt = (str*) data;
-                       reason_len = txt?txt->len:0;
+                       reason_len = txt->len;
                } else if (unlikely(cause < CANCEL_REAS_MIN)) {
                        LM_CRIT("unhandled reason cause %d\n", cause);
                        goto error;
index 3d63454..3bd76b3 100644 (file)
@@ -1004,7 +1004,7 @@ eval_flags:
                        /* find ptr to last route body that contains the (possibly) old
                         * remote target
                         */
-                       for (t = rtset, prev_t = t; t->next; prev_t = t, t = t->next)
+                       for (t = rtset, prev_t = NULL; t->next; prev_t = t, t = t->next)
                                ;
                        if ((t->ptr->len == contact->len) &&
                                        (memcmp(t->ptr->nameaddr.name.s, contact->s,
@@ -1022,7 +1022,7 @@ eval_flags:
                                if (! (t = pkg_malloc(chklen))) {
                                        ERR("out of pkg memory (%d required)\n", (int)chklen);
                                        /* last element was freed, unlink it */
-                                       if(prev_t == rtset) {
+                                       if(prev_t == NULL) {
                                                /* there is only one elem in route set: the remote target */
                                                rtset = NULL;
                                        } else {
@@ -1036,7 +1036,7 @@ eval_flags:
                                ((rr_t *)&t[1])->nameaddr.name = *contact;
                                ((rr_t *)&t[1])->len = contact->len;
                                /* chain the new route elem in set */
-                               if (prev_t == rtset)
+                               if (prev_t == NULL)
                                        /* there is only one elem in route set: the remote target */
                                        rtset = t;
                                else