diff options
author | Tomas Mraz <tomas@openssl.org> | 2024-01-05 11:01:34 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-01-08 13:52:24 +0100 |
commit | 01088602522015906654877ad2730ce805f3f925 (patch) | |
tree | 4f87addbf2338191b0f32d92a97c102a065d4d76 | |
parent | 5802de95768aabec92b1f09a1c5ae13763a8da86 (diff) |
Avoid memory leak if SXNET_add_id_INTEGER() fails
Fixes Coverity 1560046
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23211)
(cherry picked from commit 7054fc1ca3945342777f588fba43b77f669509ad)
-rw-r--r-- | crypto/x509/v3_sxnet.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/x509/v3_sxnet.c b/crypto/x509/v3_sxnet.c index 5ac3bab354..09e16956b6 100644 --- a/crypto/x509/v3_sxnet.c +++ b/crypto/x509/v3_sxnet.c @@ -123,7 +123,11 @@ int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userle ERR_raise(ERR_LIB_X509V3, X509V3_R_ERROR_CONVERTING_ZONE); return 0; } - return SXNET_add_id_INTEGER(psx, izone, user, userlen); + if (!SXNET_add_id_INTEGER(psx, izone, user, userlen)) { + ASN1_INTEGER_free(izone); + return 0; + } + return 1; } /* Add an id given the zone as an unsigned long */ @@ -139,8 +143,11 @@ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, ASN1_INTEGER_free(izone); return 0; } - return SXNET_add_id_INTEGER(psx, izone, user, userlen); - + if (!SXNET_add_id_INTEGER(psx, izone, user, userlen)) { + ASN1_INTEGER_free(izone); + return 0; + } + return 1; } /* |