From: Alan T. DeKok Date: Fri, 8 Sep 2023 20:12:55 +0000 (-0400) Subject: only free the the vp on the error path X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6b6d23ac1bc3fd686926f52b4ddac3a51cfd28f;p=thirdparty%2Ffreeradius-server.git only free the the vp on the error path if the first byte is non-zero, then the result is non-zero, and we don't need to check it on all paths --- diff --git a/src/protocols/dhcpv4/packet.c b/src/protocols/dhcpv4/packet.c index 0a3951f7da2..79a3c8e25d1 100644 --- a/src/protocols/dhcpv4/packet.c +++ b/src/protocols/dhcpv4/packet.c @@ -147,8 +147,9 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, q = memchr(p, '\0', dhcp_header_sizes[i]); fr_pair_value_bstrndup(vp, (char const *)p, q ? q - p : dhcp_header_sizes[i], true); + } else { + TALLOC_FREE(vp); } - if (vp->vp_length == 0) TALLOC_FREE(vp); break; /*