From ae9e22ab3fadd1ca300902d952d340a70d2e9ce5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Sun, 23 Nov 2025 15:15:33 +0100 Subject: [PATCH] netlink: make it clearer that we're handling realloc correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Link: https://github.com/openwrt/odhcpd/pull/320 Signed-off-by: Álvaro Fernández Rojas --- src/netlink.c | 8 ++++---- 1 file 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; -- 2.30.2