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:23 +1000
commitb2feb9f0e394da6570346598837f1b01eb58c028 (patch)
tree43bd3248f7b52bbab9ccd5776a503d56c7fdb75d /test
parent16249341bb64329c2542c3d1e23b97ed3c44fad3 (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)
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 b011534220..beabb7205e 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;