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:12 +0100 |
commit | 4001226834c502859186e2c1d0c5c91f63f542c0 (patch) | |
tree | 473c5ebf8165c80f291994ed531f2bc09f254559 | |
parent | bef1ef36a13a4174d5907f5ecce11b7e17b06129 (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 8540f10d1e..36620a2b67 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; } /* |