Commit 90945fa3 authored by Matt Caswell's avatar Matt Caswell
Browse files

Continue standardising malloc style for libcrypto

Continuing from previous commit ensure our style is consistent for malloc
return checks.

Reviewed-by: default avatarKurt Roeckx <kurt@openssl.org>
parent a71edf3b
Loading
Loading
Loading
Loading
+1 −1
Changes for crypto/asn1/a_mbstr.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
    } else {
        free_out = 1;
        dest = ASN1_STRING_type_new(str_type);
        if (!dest) {
        if (dest == NULL) {
            ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE);
            return -1;
        }
+4 −4
Changes for crypto/asn1/a_object.c: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -139,9 +139,9 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
            }
            if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) {
                use_bn = 1;
                if (!bl)
                if (bl == NULL)
                    bl = BN_new();
                if (!bl || !BN_set_word(bl, l))
                if (bl == NULL || !BN_set_word(bl, l))
                    goto err;
            }
            if (use_bn) {
@@ -173,7 +173,7 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
                    OPENSSL_free(tmp);
                tmpsize = blsize + 32;
                tmp = OPENSSL_malloc(tmpsize);
                if (!tmp)
                if (tmp == NULL)
                    goto err;
            }
            while (blsize--)
@@ -225,7 +225,7 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
    i = i2t_ASN1_OBJECT(buf, sizeof buf, a);
    if (i > (int)(sizeof(buf) - 1)) {
        p = OPENSSL_malloc(i + 1);
        if (!p)
        if (p == NULL)
            return -1;
        i2t_ASN1_OBJECT(p, i + 1, a);
    }
+1 −1
Changes for crypto/asn1/a_strex.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ static int do_dump(unsigned long lflags, char_io *io_ch, void *arg,
    t.value.ptr = (char *)str;
    der_len = i2d_ASN1_TYPE(&t, NULL);
    der_buf = OPENSSL_malloc(der_len);
    if (!der_buf)
    if (der_buf == NULL)
        return -1;
    p = der_buf;
    i2d_ASN1_TYPE(&t, &p);
+3 −3
Changes for crypto/asn1/a_strnid.c: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -235,16 +235,16 @@ static ASN1_STRING_TABLE *stable_get(int nid)
{
    ASN1_STRING_TABLE *tmp, *rv;
    /* Always need a string table so allocate one if NULL */
    if (!stable) {
    if (stable == NULL) {
        stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
        if (!stable)
        if (stable == NULL)
            return NULL;
    }
    tmp = ASN1_STRING_TABLE_get(nid);
    if (tmp && tmp->flags & STABLE_FLAGS_MALLOC)
        return tmp;
    rv = OPENSSL_malloc(sizeof(*rv));
    if (!rv)
    if (rv == NULL)
        return NULL;
    if (!sk_ASN1_STRING_TABLE_push(stable, rv)) {
        OPENSSL_free(rv);
+3 −3
Changes for crypto/asn1/ameth_lib.c: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth)
{
    if (app_methods == NULL) {
        app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp);
        if (!app_methods)
        if (app_methods == NULL)
            return 0;
    }
    if (!sk_EVP_PKEY_ASN1_METHOD_push(app_methods, ameth))
@@ -237,7 +237,7 @@ int EVP_PKEY_asn1_add_alias(int to, int from)
{
    EVP_PKEY_ASN1_METHOD *ameth;
    ameth = EVP_PKEY_asn1_new(from, ASN1_PKEY_ALIAS, NULL, NULL);
    if (!ameth)
    if (ameth == NULL)
        return 0;
    ameth->pkey_base_id = to;
    if (!EVP_PKEY_asn1_add0(ameth)) {
@@ -277,7 +277,7 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
{
    EVP_PKEY_ASN1_METHOD *ameth = OPENSSL_zalloc(sizeof(*ameth));

    if (!ameth)
    if (ameth == NULL)
        return NULL;

    ameth->pkey_id = id;
Loading