ssl3_free(): Return if it wasn't created
authorPascal Cuoq <cuoq@trust-in-soft.com>
Sun, 22 Nov 2015 23:13:15 +0000 (00:13 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Tue, 24 Nov 2015 21:01:35 +0000 (22:01 +0100)
If somewhere in SSL_new() there is a memory allocation failure, ssl3_free() can
get called with s->s3 still being NULL.

Patch also provided by Willy Tarreau <wtarreau@haproxy.com>

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Viktor Dukhovni <openssl-users@dukhovni.org>
ssl/s3_lib.c

index f40b1437939c393902743013d620090728b95a9a..5ad9863121eaf4670d78c4efd1fd2ec6be67d8fc 100644 (file)
@@ -3880,7 +3880,7 @@ int ssl3_new(SSL *s)
 
 void ssl3_free(SSL *s)
 {
-    if (s == NULL)
+    if (s == NULL || s->s3 == NULL)
         return;
 
     ssl3_cleanup_key_block(s);