Skip to content

Commit

Permalink
test/ssl_old_test.c: Add check for OPENSSL_malloc
Browse files Browse the repository at this point in the history
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 #18555)

(cherry picked from commit b2feb9f)
  • Loading branch information
JiangJias authored and paulidale committed Jun 16, 2022
1 parent d8e2dc5 commit 0da1e36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/ssl_old_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0da1e36

Please sign in to comment.