]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/ssl_old_test.c: Add check for OPENSSL_malloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 14 Jun 2022 09:15:05 +0000 (17:15 +0800)
committerPauli <pauli@openssl.org>
Thu, 16 Jun 2022 05:18:23 +0000 (15:18 +1000)
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)

test/ssl_old_test.c

index b011534220e4a21c69f726f6ffcf8a58c66e734c..beabb7205ed5d4a46a1167af92791bbf8900c0b9 100644 (file)
@@ -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;