From 62f488d31733e5dc77b339f905b44f165550e47d Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 20 Mar 2017 20:50:23 +0100 Subject: [PATCH] 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) --- crypto/ex_data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.25.1