summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2022-06-14 17:15:05 +0800
committerPauli <pauli@openssl.org>2022-06-16 15:18:49 +1000
commit0da1e36d2026861b445c743b62c854e8cc2171ab (patch)
treeb6646d5f3f2275772a9f50f96c8a1474baff353c /test
parentd8e2dc576571de48f85d106d1f3e5da604bd2c9a (diff)
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 <jiasheng@iscas.ac.cn> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18555) (cherry picked from commit b2feb9f0e394da6570346598837f1b01eb58c028)
Diffstat (limited to 'test')
-rw-r--r--test/ssl_old_test.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c
index bbe95d70f9..91c8b5b7b5 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;