From: Bernd Edlinger Date: Mon, 20 Mar 2017 19:50:23 +0000 (+0100) Subject: Fix the error handling in CRYPTO_dup_ex_data. X-Git-Tag: OpenSSL_1_0_2l~28 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=62f488d;p=oweals%2Fopenssl.git Fix the error handling in CRYPTO_dup_ex_data. Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/2998) --- diff --git a/crypto/ex_data.c b/crypto/ex_data.c index d947f3edac..108a1959ea 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -459,7 +459,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from) { int mx, j, i; - char *ptr; + void *ptr; CRYPTO_EX_DATA_FUNCS **storage = NULL; EX_CLASS_ITEM *item; if (!from->sk) @@ -473,6 +473,8 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, if (j < mx) mx = j; if (mx > 0) { + if (!CRYPTO_set_ex_data(to, mx - 1, NULL)) + goto skip; storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *)); if (!storage) goto skip;