]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for switch_stun.c
authorAndrey Volk <andywolk@gmail.com>
Fri, 12 Jul 2019 16:46:20 +0000 (20:46 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 15 Jul 2019 19:45:32 +0000 (23:45 +0400)
src/switch_stun.c

index 94ee890f7832f7be707ac33d43fc819c5c819938..b60a3cd5ea64ddc19ac004fc62f614d2073b649d 100644 (file)
@@ -809,26 +809,23 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
        end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
 
        switch_stun_packet_first_attribute(packet, attr);
+       switch_assert(attr);
+
+
        do {
                switch (attr->type) {
                case SWITCH_STUN_ATTR_MAPPED_ADDRESS:
-                       if (attr->type) {
-                               if (funny) {
-                                       switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr->value;
-                                       tmp->address ^= ntohl(0xabcdabcd);
-                               }
-                               switch_stun_packet_attribute_get_mapped_address(attr, rip, sizeof(rip), &rport);
+                       if (funny) {
+                               switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr->value;
+                               tmp->address ^= ntohl(0xabcdabcd);
                        }
+                       switch_stun_packet_attribute_get_mapped_address(attr, rip, sizeof(rip), &rport);
                        break;
                case SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS:
-                       if (attr->type) {
-                               switch_stun_packet_attribute_get_xor_mapped_address(attr, &packet->header, rip, sizeof(rip), &rport);
-                       }
+                       switch_stun_packet_attribute_get_xor_mapped_address(attr, &packet->header, rip, sizeof(rip), &rport);
                        break;
                case SWITCH_STUN_ATTR_USERNAME:
-                       if (attr->type) {
-                               switch_stun_packet_attribute_get_username(attr, username, 32);
-                       }
+                       switch_stun_packet_attribute_get_username(attr, username, 32);
                        break;
                }