Skip to content

Commit

Permalink
Fix a failure to NULL a pointer freed on error.
Browse files Browse the repository at this point in the history
Inspired by BoringSSL commit 517073cd4b by Eric Roman <eroman@chromium.org>

CVE-2015-0209

Reviewed-by: Emilia Käsper <emilia@openssl.org>
  • Loading branch information
mattcaswell committed Feb 25, 2015
1 parent 71ea6b4 commit 9e442d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crypto/ec/ec_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
goto err;
}
if (a)
*a = ret;
} else
ret = *a;

Expand Down Expand Up @@ -1102,10 +1100,12 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
ret->enc_flag |= EC_PKEY_NO_PUBKEY;
}

if (a)
*a = ret;
ok = 1;
err:
if (!ok) {
if (ret)
if (ret && (a == NULL || *a != ret))
EC_KEY_free(ret);
ret = NULL;
}
Expand Down

0 comments on commit 9e442d4

Please sign in to comment.