Skip to content

Commit 1b4a8df

Browse files
committed
Fix a failure to NULL a pointer freed on error.
Inspired by BoringSSL commit 517073cd4b by Eric Roman <eroman@chromium.org> CVE-2015-0209 Reviewed-by: Emilia Käsper <emilia@openssl.org>
1 parent 6d4655c commit 1b4a8df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crypto/ec/ec_asn1.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
10141014
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
10151015
goto err;
10161016
}
1017-
if (a)
1018-
*a = ret;
10191017
} else
10201018
ret = *a;
10211019

@@ -1067,10 +1065,12 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
10671065
}
10681066
}
10691067

1068+
if (a)
1069+
*a = ret;
10701070
ok = 1;
10711071
err:
10721072
if (!ok) {
1073-
if (ret)
1073+
if (ret && (a == NULL || *a != ret))
10741074
EC_KEY_free(ret);
10751075
ret = NULL;
10761076
}

0 commit comments

Comments
 (0)