summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2024-04-11 09:40:18 +0200
committerTomas Mraz <tomas@openssl.org>2024-04-12 10:57:25 +0200
commitd207c4c44215e44b92fd031bf84ff3045055b3bf (patch)
tree06691d01a151fccacdd8ac53b758bd27bb4d4f32
parentd3de76dca4f9967f1f746048ffab819319c057fb (diff)
make_addressPrefix(): Fix a memory leak in error case
Fixes #24098 Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24102) (cherry picked from commit 682ed1b86ebe97036ab37897d528343d0e4def69)
-rw-r--r--crypto/x509/v3_addr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/x509/v3_addr.c b/crypto/x509/v3_addr.c
index 56f269333e..99079472ad 100644
--- a/crypto/x509/v3_addr.c
+++ b/crypto/x509/v3_addr.c
@@ -403,11 +403,11 @@ static int make_addressPrefix(IPAddressOrRange **result, unsigned char *addr,
const int prefixlen, const int afilen)
{
int bytelen = (prefixlen + 7) / 8, bitlen = prefixlen % 8;
- IPAddressOrRange *aor = IPAddressOrRange_new();
+ IPAddressOrRange *aor;
if (prefixlen < 0 || prefixlen > (afilen * 8))
return 0;
- if (aor == NULL)
+ if ((aor = IPAddressOrRange_new()) == NULL)
return 0;
aor->type = IPAddressOrRange_addressPrefix;
if (aor->u.addressPrefix == NULL &&