MT#57409 warning: '<anonymous>' may be used uninitialized in this function

This commit fixes the following issue:

     In file included from AmConfig.h:31,
                      from AmSdp.cpp:12:
     AmSdp.h: In member function 'void AmSdp::clear()':
     AmSdp.h:61:8: warning: '<anonymous>' may be used uninitialized in this function [-Wmaybe-uninitialized]
        61 | struct SdpConnection
           |        ^~~~~~~~~~~~~
     AmSdp.h:61:8: warning: '<anonymous>.SdpConnection::ipv4' may be used uninitialized in this function [-Wmaybe-uninitialized]
     AmSdp.h:61:8: warning: '<anonymous>.SdpConnection::ipv6' may be used uninitialized in this function [-Wmaybe-uninitialized]

When calling the SdpConnection's constructor in the AmSdp::clear(),
we initialize the `address` member, but not the `ipv4` and `ipv6` members.

Therefore, when the `AmSdp::clear()` is called,
it's possible that the `ipv4` and `ipv6` members of the `SdpConnection` object may contain garbage values.

To fix the issue, we should explicitly initialize
the `ipv4` and `ipv6` members in the default constructor of `SdpConnection`.

With this change, we explicitely initialize the `ipv4` and `ipv6` members to their
default-constructed values, which in this case will be all zeroes.

Additionally: explicitely initialize the `network` and `addrType` to zeroes.

Change-Id: Iaabb4aa2f2fafd0eb83e3f79becc3bd8d54de32e
mr11.4.1
Donat Zenichev 3 years ago
parent 678730d7b5
commit e79e20c3bd

@ -70,7 +70,7 @@ struct SdpConnection
/** IP address */
string address;
SdpConnection() : address() {}
SdpConnection() : network(0), addrType(0), address(), ipv4{}, ipv6{} {}
bool operator == (const SdpConnection& other) const;
/** pretty print */

Loading…
Cancel
Save