mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 18:20:10 +01:00
platform: use proper g_free() function for netlink receive buffer
In the past, nl_recv() was libnl3 code and thus used malloc()/realloc() to allocate the buffer. That meant, we should free the buffer with libc's free() function instead of glib's g_free(). That is what nm_auto_free is for. Nowadays, nl_recv() is forked and glib-ified, and uses the glib wrappers to allocate the buffer. Thus the buffer should also be freed with g_free() (and gs_free). In practice there is no difference, because glib's allocation directly uses libc's malloc/free. This is purely a matter of style.
This commit is contained in:
parent
5153810bd6
commit
340f05ba42
1 changed files with 14 additions and 13 deletions
|
|
@ -9021,21 +9021,22 @@ event_handler(int fd, GIOCondition io_condition, gpointer user_data)
|
|||
static int
|
||||
event_handler_recvmsgs(NMPlatform *platform, gboolean handle_events)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform);
|
||||
struct nl_sock *sk = priv->nlh;
|
||||
int n;
|
||||
int err = 0;
|
||||
gboolean multipart = 0;
|
||||
gboolean interrupted = FALSE;
|
||||
struct nlmsghdr *hdr;
|
||||
WaitForNlResponseResult seq_result;
|
||||
struct sockaddr_nl nla = {0};
|
||||
struct ucred creds;
|
||||
gboolean creds_has;
|
||||
nm_auto_free unsigned char *buf = NULL;
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform);
|
||||
struct nl_sock *sk = priv->nlh;
|
||||
int n;
|
||||
int err = 0;
|
||||
gboolean multipart = 0;
|
||||
gboolean interrupted = FALSE;
|
||||
struct nlmsghdr *hdr;
|
||||
WaitForNlResponseResult seq_result;
|
||||
struct sockaddr_nl nla = {0};
|
||||
struct ucred creds;
|
||||
gboolean creds_has;
|
||||
gs_free unsigned char *buf = NULL;
|
||||
|
||||
continue_reading:
|
||||
nm_clear_pointer(&buf, free);
|
||||
nm_clear_g_free(&buf);
|
||||
|
||||
n = nl_recv(sk, &nla, &buf, &creds, &creds_has);
|
||||
|
||||
if (n <= 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue