aboutsummaryrefslogtreecommitdiff
path: root/crypto/x509v3/v3_utl.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-10-30 11:12:26 +0000
committerMatt Caswell <matt@openssl.org>2015-11-09 22:48:41 +0000
commit90945fa31a42dcf3beb90540c618e4d627c595ea (patch)
treee73870c253abf0c37ca618384e30a7937a996b55 /crypto/x509v3/v3_utl.c
parenta71edf3ba275b946224b5bcded0a8ecfce1855c0 (diff)
downloadopenssl-90945fa31a42dcf3beb90540c618e4d627c595ea.zip
openssl-90945fa31a42dcf3beb90540c618e4d627c595ea.tar.gz
openssl-90945fa31a42dcf3beb90540c618e4d627c595ea.tar.bz2
Continue standardising malloc style for libcrypto
Continuing from previous commit ensure our style is consistent for malloc return checks. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/x509v3/v3_utl.c')
-rw-r--r--crypto/x509v3/v3_utl.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 6494d83..8481749 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -176,11 +176,15 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
ASN1_INTEGER *aint;
int isneg, ishex;
int ret;
- if (!value) {
+ if (value == NULL) {
X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_INVALID_NULL_VALUE);
- return 0;
+ return NULL;
}
bn = BN_new();
+ if (bn == NULL) {
+ X509V3err(X509V3_F_S2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
if (value[0] == '-') {
value++;
isneg = 1;
@@ -201,7 +205,7 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
if (!ret || value[ret]) {
BN_free(bn);
X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_BN_DEC2BN_ERROR);
- return 0;
+ return NULL;
}
if (isneg && BN_is_zero(bn))
@@ -212,7 +216,7 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
if (!aint) {
X509V3err(X509V3_F_S2I_ASN1_INTEGER,
X509V3_R_BN_TO_ASN1_INTEGER_ERROR);
- return 0;
+ return NULL;
}
if (isneg)
aint->type |= V_ASN1_NEG;
@@ -606,15 +610,15 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
return 1;
if (!email->data || !email->length)
return 1;
- if (!*sk)
+ if (*sk == NULL)
*sk = sk_OPENSSL_STRING_new(sk_strcmp);
- if (!*sk)
+ if (*sk == NULL)
return 0;
/* Don't add duplicates */
if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
return 1;
emtmp = BUF_strdup((char *)email->data);
- if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
+ if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
X509_email_free(*sk);
*sk = NULL;
return 0;
@@ -1077,7 +1081,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc)
return NULL;
ret = ASN1_OCTET_STRING_new();
- if (!ret)
+ if (ret == NULL)
return NULL;
if (!ASN1_OCTET_STRING_set(ret, ipout, iplen)) {
ASN1_OCTET_STRING_free(ret);
@@ -1115,7 +1119,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
goto err;
ret = ASN1_OCTET_STRING_new();
- if (!ret)
+ if (ret == NULL)
goto err;
if (!ASN1_OCTET_STRING_set(ret, ipout, iplen1 + iplen2))
goto err;