From: Jiasheng Jiang Date: Tue, 14 Jun 2022 09:15:05 +0000 (+0800) Subject: test/ssl_old_test.c: Add check for OPENSSL_malloc X-Git-Tag: openssl-3.2.0-alpha1~2524 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2feb9f0e394da6570346598837f1b01eb58c028;p=thirdparty%2Fopenssl.git test/ssl_old_test.c: Add check for OPENSSL_malloc As the potential failure of the OPENSSL_malloc(), it should be better to add the check and return error if fails. Signed-off-by: Jiasheng Jiang Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18555) --- diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c index b011534220e..beabb7205ed 100644 --- a/test/ssl_old_test.c +++ b/test/ssl_old_test.c @@ -310,6 +310,11 @@ static int cb_server_alpn(SSL *s, const unsigned char **out, * verify_alpn. */ alpn_selected = OPENSSL_malloc(*outlen); + if (alpn_selected == NULL) { + fprintf(stderr, "failed to allocate memory\n"); + OPENSSL_free(protos); + abort(); + } memcpy(alpn_selected, *out, *outlen); *out = alpn_selected;