summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman2025-11-23 14:15:33 +0000
committerÁlvaro Fernández Rojas2025-11-27 07:24:53 +0000
commitae9e22ab3fadd1ca300902d952d340a70d2e9ce5 (patch)
tree824e68305adb8c5783538aef32db402f4fb15b9d
parentb9db4d7061a08bf82a25222074065cce71973d0c (diff)
downloadodhcpd-ae9e22ab3fadd1ca300902d952d340a70d2e9ce5.tar.gz
netlink: make it clearer that we're handling realloc correctly
This doesn't really change the code, it just makes it clearer when grepping for realloc() that failure is handled correctly. Signed-off-by: David Härdeman <david@hardeman.nu> Link: https://github.com/openwrt/odhcpd/pull/320 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
-rw-r--r--src/netlink.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/netlink.c b/src/netlink.c
index c07a9e4..d58e452 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -531,7 +531,7 @@ struct addr_info {
static int cb_addr_valid(struct nl_msg *msg, void *arg)
{
struct addr_info *ctxt = (struct addr_info *)arg;
- struct odhcpd_ipaddr *oaddrs = *(ctxt->oaddrs);
+ struct odhcpd_ipaddr *oaddrs;
struct nlmsghdr *hdr = nlmsg_hdr(msg);
struct ifaddrmsg *ifa;
struct nlattr *nla[__IFA_MAX], *nla_addr = NULL;
@@ -564,7 +564,7 @@ static int cb_addr_valid(struct nl_msg *msg, void *arg)
if (!nla_addr)
return NL_SKIP;
- oaddrs = realloc(oaddrs, sizeof(*oaddrs) * (ctxt->ret + 1));
+ oaddrs = realloc(*(ctxt->oaddrs), sizeof(*oaddrs) * (ctxt->ret + 1));
if (!oaddrs)
return NL_SKIP;
@@ -721,7 +721,7 @@ out:
static int cb_linklocal_valid(struct nl_msg *msg, void *arg)
{
struct addr_info *ctxt = (struct addr_info *)arg;
- struct odhcpd_ipaddr *oaddrs = *(ctxt->oaddrs);
+ struct odhcpd_ipaddr *oaddrs;
struct nlmsghdr *hdr = nlmsg_hdr(msg);
struct ifaddrmsg *ifa;
struct nlattr *nla[__IFA_MAX], *nla_addr = NULL;
@@ -755,7 +755,7 @@ static int cb_linklocal_valid(struct nl_msg *msg, void *arg)
if (!IN6_IS_ADDR_LINKLOCAL(&addr))
return NL_SKIP;
- oaddrs = realloc(oaddrs, sizeof(*oaddrs) * (ctxt->ret + 1));
+ oaddrs = realloc(*(ctxt->oaddrs), sizeof(*oaddrs) * (ctxt->ret + 1));
if (!oaddrs)
return NL_SKIP;