Re: [PATCH 4/8] vpn: Fix mem leak on nameservers
Jussi Laakkonen <[email protected]> Tue, 15 Apr 2025 12:19:20 +0300
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
Hi Denis,
On 4/14/25 18:38, Denis Kenzior wrote:
> Hi Jussi,
>
> On 4/10/25 10:58 AM, Jussi Laakkonen wrote:
>> Fix Clang analyzer complaint about mem leak on nameservers.
>> ---
>> plugins/vpn.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/plugins/vpn.c b/plugins/vpn.c
>> index 9664c82f..9e6e26bf 100644
>> --- a/plugins/vpn.c
>> +++ b/plugins/vpn.c
>> @@ -472,8 +472,10 @@ static int extract_nameservers(DBusMessageIter
>> *array,
>> DBG("[%d] %s", i, nameserver);
>>
>> nameservers[i] = g_strdup(nameserver);
>> - if (!nameservers[i])
>> + if (!nameservers[i]) {
>
> g_strdup() doesn't fail (it aborts). So I'm not sure what this is
> trying to fix?
Yeah... I guess I fell into the paranoid way of Clang analyzer in this
one. Getting a NULL from D-Bus for nameserver might not be possible
either. Yeah, maybe these small allocations should be treated
differently. Can be skipped for sure.
>
>> + g_strfreev(nameservers);
>> return -ENOMEM;
>> + }
>>
>> nameservers[++i] = NULL;
>>
>> --
>> 2.39.5
>>
>>
>
Cheers,
Jussi