Tighten sanity checks when calling early data functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2737)
diff --git a/apps/s_client.c b/apps/s_client.c
index 3ecc601..c11a634 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -2359,7 +2359,9 @@
         break;
     }
 
-    if (early_data_file != NULL) {
+    if (early_data_file != NULL
+            && SSL_get0_session(con) != NULL
+            && SSL_SESSION_get_max_early_data(SSL_get0_session(con)) > 0) {
         BIO *edfile = BIO_new_file(early_data_file, "r");
         size_t readbytes, writtenbytes;
         int finish = 0;