Fix OpenSSL use-after-free