]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
only free the the vp on the error path
authorAlan T. DeKok <aland@freeradius.org>
Fri, 8 Sep 2023 20:12:55 +0000 (16:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 8 Sep 2023 20:12:55 +0000 (16:12 -0400)
if the first byte is non-zero, then the result is non-zero,
and we don't need to check it on all paths

src/protocols/dhcpv4/packet.c

index 0a3951f7da2e141b852849e6b8ec91bec6863a38..79a3c8e25d1ff2eeb7f37198daa48d33a8fda563 100644 (file)
@@ -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;
 
                        /*