[glib: 4/9] gsocket: Clear address before filling it
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 4/9] gsocket: Clear address before filling it
- Date: Thu, 28 Apr 2022 11:07:36 +0000 (UTC)
commit 7f83151ac0f72bc0244acd27cbb658edf5ab049b
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Apr 28 10:50:08 2022 +0100
gsocket: Clear address before filling it
This will probably make no functional difference, but will squash two
warnings from scan-build:
```
../../../../source/glib/gio/gsocket.c:503:14: warning: Assigned value is garbage or undefined
[core.uninitialized.Assign]
family = address.storage.ss_family;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../source/glib/gio/gsocket.c:527:29: warning: Assigned value is garbage or undefined
[core.uninitialized.Assign]
socket->priv->family = address.storage.ss_family;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
```
It seems like a reasonable thing to warn about. Initialising the full
union to zero should avoid any possibility of undefined behaviour like
that.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1767
gio/gsocket.c | 2 ++
1 file changed, 2 insertions(+)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index b19a9a3731..f22f6b703b 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -463,6 +463,8 @@ g_socket_details_from_fd (GSocket *socket)
int value, family;
int errsv;
+ memset (&address, 0, sizeof (address));
+
fd = socket->priv->fd;
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]