]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[sofia-sip] scan-build: Fix "Dereference of null pointer" in outgoing_answer_srv(). 396/head
authorAndrey Volk <andywolk@gmail.com>
Thu, 20 Feb 2020 18:24:42 +0000 (22:24 +0400)
committerAndrey Volk <andywolk@gmail.com>
Thu, 20 Feb 2020 18:44:51 +0000 (22:44 +0400)
libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/nta/nta.c

index e3d9f5f204a6a91f81f2bc1eeed8bd4ba3e97db6..4dd82d032be96bd6f0a010012f497d3cc5e3e5e4 100644 (file)
@@ -1 +1 @@
-Thu Feb 20 11:10:22 UTC 2020
+Thu Feb 20 12:12:22 UTC 2020
index e5f60e91eeb427b8459c4ad6d481f3a1feb133aa..81f849aea886dc40c9137fa21cb6374d2b6a4863 100644 (file)
@@ -10694,22 +10694,24 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
     if (N > 1 && weight > 0) {
       unsigned rand = su_randint(0,  weight - 1);
 
-      while (rand >= (*tail)->sq_weight) {
+      while (*tail && rand >= (*tail)->sq_weight) {
        rand -= (*tail)->sq_weight;
        tail = &(*tail)->sq_next;
       }
     }
 
     /* Remove selected */
-    sq = *tail; *tail = sq->sq_next; assert(sq->sq_priority == priority);
+    if (*tail) {
+      sq = *tail; *tail = sq->sq_next; assert(sq->sq_priority == priority);
 
-    /* Append at *at */
-    sq->sq_next = *at; *at = sq; at = &sq->sq_next; if (!*at) sr->sr_tail = at;
+      /* Append at *at */
+      sq->sq_next = *at; *at = sq; at = &sq->sq_next; if (!*at) sr->sr_tail = at;
 
-    SU_DEBUG_5(("nta: %s IN SRV %u %u  %s %s (%s)\n",
-               sq0->sq_domain,
-               (unsigned)sq->sq_priority, (unsigned)sq->sq_weight,
-               sq->sq_port, sq->sq_domain, sq->sq_proto));
+      SU_DEBUG_5(("nta: %s IN SRV %u %u  %s %s (%s)\n",
+                 sq0->sq_domain,
+                 (unsigned)sq->sq_priority, (unsigned)sq->sq_weight,
+                 sq->sq_port, sq->sq_domain, sq->sq_proto));
+    }
   }
 
   /* This is not needed anymore (?) */