From e79e20c3bdeb25439b966859c29a24f9c0fbafd7 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Thu, 11 May 2023 14:33:37 +0200 Subject: [PATCH] MT#57409 warning: '' 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: '' may be used uninitialized in this function [-Wmaybe-uninitialized] 61 | struct SdpConnection | ^~~~~~~~~~~~~ AmSdp.h:61:8: warning: '.SdpConnection::ipv4' may be used uninitialized in this function [-Wmaybe-uninitialized] AmSdp.h:61:8: warning: '.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 --- core/AmSdp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/AmSdp.h b/core/AmSdp.h index 1207f2c3..d7408195 100644 --- a/core/AmSdp.h +++ b/core/AmSdp.h @@ -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 */