From 50843b22cd0ba6021bb6a4ce87461425efe93696 Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Mon, 18 Jan 2021 16:18:49 -0600 Subject: [PATCH 1/2] Check method for NULL --- examples/client/client.c | 9 ++++++--- examples/server/server.c | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/client/client.c b/examples/client/client.c index 95c59efca..cb8325801 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -2414,9 +2414,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) err_sys("unable to load static memory"); } #else - ctx = wolfSSL_CTX_new(method(NULL)); - if (ctx == NULL) - err_sys("unable to get ctx"); + else { + /* method is not NULL */ + ctx = wolfSSL_CTX_new(method(NULL)); + if (ctx == NULL) + err_sys("unable to get ctx"); + } #endif if (simulateWantWrite) diff --git a/examples/server/server.c b/examples/server/server.c index 4a7dda504..90950800d 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -1729,7 +1729,10 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) != WOLFSSL_SUCCESS) err_sys_ex(catastrophic, "unable to load static memory and create ctx"); #else - ctx = SSL_CTX_new(method(NULL)); + else { + /* method is not NULL */ + ctx = SSL_CTX_new(method(NULL)); + } #endif /* WOLFSSL_STATIC_MEMORY */ if (ctx == NULL) err_sys_ex(catastrophic, "unable to get ctx"); From a3cbcf255f881e00ec6add7192a8377d278ceeac Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Wed, 20 Jan 2021 11:34:02 -0600 Subject: [PATCH 2/2] Fix from review --- examples/client/client.c | 3 +-- examples/server/server.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/client/client.c b/examples/client/client.c index cb8325801..79aece83e 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -2414,8 +2414,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) err_sys("unable to load static memory"); } #else - else { - /* method is not NULL */ + if (method != NULL) { ctx = wolfSSL_CTX_new(method(NULL)); if (ctx == NULL) err_sys("unable to get ctx"); diff --git a/examples/server/server.c b/examples/server/server.c index 90950800d..1cef6324a 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -1729,8 +1729,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) != WOLFSSL_SUCCESS) err_sys_ex(catastrophic, "unable to load static memory and create ctx"); #else - else { - /* method is not NULL */ + if (method != NULL) { ctx = SSL_CTX_new(method(NULL)); } #endif /* WOLFSSL_STATIC_MEMORY */