diff options
author | Andy Polyakov <appro@openssl.org> | 2017-10-08 20:10:13 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2017-10-10 20:00:35 +0200 |
commit | 32f3b98d1302d4c0950dc1bf94b50269b6edbd95 (patch) | |
tree | 3e7dacbbb5f82e5555e56009678d7a17433df941 /crypto | |
parent | 65e6b9a42364d7dd1108d952ff1c58f3b911ddc0 (diff) | |
download | openssl-32f3b98d1302d4c0950dc1bf94b50269b6edbd95.zip openssl-32f3b98d1302d4c0950dc1bf94b50269b6edbd95.tar.gz openssl-32f3b98d1302d4c0950dc1bf94b50269b6edbd95.tar.bz2 |
crypto/x509v3/v3_utl.c, ssl/ssl_cert.c: fix Coverity problems.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4492)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/x509v3/v3_utl.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c index 8bba5a6..a839861 100644 --- a/crypto/x509v3/v3_utl.c +++ b/crypto/x509v3/v3_utl.c @@ -38,6 +38,7 @@ int X509V3_add_value(const char *name, const char *value, { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; + int sk_allocated = (*extlist == NULL); if (name && (tname = OPENSSL_strdup(name)) == NULL) goto err; @@ -45,7 +46,7 @@ int X509V3_add_value(const char *name, const char *value, goto err; if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; - if (*extlist == NULL && (*extlist = sk_CONF_VALUE_new_null()) == NULL) + if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) goto err; vtmp->section = NULL; vtmp->name = tname; @@ -55,6 +56,8 @@ int X509V3_add_value(const char *name, const char *value, return 1; err: X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE); + if (sk_allocated) + sk_CONF_VALUE_free(*extlist); OPENSSL_free(vtmp); OPENSSL_free(tname); OPENSSL_free(tvalue); |