ssl: Do not request or set hints when handshake is torn down

Signed-off-by: Xiangfei Ding <xfding@google.com>
Change-Id: Ibd793e5f123831ee25d79870c777536f6a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/98047
Reviewed-by: Lily Chen <chlily@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/ssl/handoff.cc b/ssl/handoff.cc
index 67ce1e5..b00514e 100644
--- a/ssl/handoff.cc
+++ b/ssl/handoff.cc
@@ -821,7 +821,7 @@
                                 size_t client_hello_len,
                                 const uint8_t *capabilities,
                                 size_t capabilities_len) {
-  if (SSL_is_dtls(ssl)) {
+  if (SSL_is_dtls(ssl) || ssl->s3->hs == nullptr) {
     OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
     return 0;
   }
@@ -1064,7 +1064,7 @@
 }
 
 int SSL_set_handshake_hints(SSL *ssl, const uint8_t *hints, size_t hints_len) {
-  if (SSL_is_dtls(ssl)) {
+  if (SSL_is_dtls(ssl) || ssl->s3->hs == nullptr) {
     OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
     return 0;
   }