From 78a428dbd0306c6797443432391e6aa6baf10ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 29 Jun 2015 19:00:15 +0200 Subject: [PATCH] Fix unchecked malloc() Found using Infer. --- library/ssl_tls.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 709f23068..41722e8fd 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3066,6 +3066,11 @@ int ssl_init( ssl_context *ssl ) ssl->min_minor_ver = SSL_MINOR_VERSION_0; ssl->ciphersuites = malloc( sizeof(int *) * 4 ); + if( ssl->ciphersuites == NULL ) + { + SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", sizeof(int *) * 4) ); + return( POLARSSL_ERR_SSL_MALLOC_FAILED ); + } ssl_set_ciphersuites( ssl, ssl_default_ciphersuites ); #if defined(POLARSSL_DHM_C)