goto out_free;
rsa = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL);
- BIO_free(bio);
+ BIO_free_all(bio);
if (!rsa)
{
if (!rdg)
return;
- if (rdg->tlsOut)
- {
- tls_free(rdg->tlsOut);
- rdg->tlsOut = NULL;
- }
-
- if (rdg->tlsIn)
- {
- tls_free(rdg->tlsIn);
- rdg->tlsIn = NULL;
- }
-
- if (rdg->http)
- {
- http_context_free(rdg->http);
- rdg->http = NULL;
- }
-
- if (rdg->ntlm)
- {
- ntlm_free(rdg->ntlm);
- rdg->ntlm = NULL;
- }
-
+ tls_free(rdg->tlsOut);
+ tls_free(rdg->tlsIn);
+ http_context_free(rdg->http);
+ ntlm_free(rdg->ntlm);
+ BIO_free_all(rdg->frontBio);
DeleteCriticalSection(&rdg->writeSection);
free(rdg);
}
return 1;
}
+/* Free the buffered BIO.
+ * Do not free other elements in the BIO stack,
+ * let BIO_free_all handle that. */
static int transport_bio_buffered_free(BIO* bio)
{
WINPR_BIO_BUFFERED_SOCKET* ptr = (WINPR_BIO_BUFFERED_SOCKET*) BIO_get_data(bio);
- BIO* next_bio = BIO_next(bio);
- if (next_bio)
- {
- BIO_free(next_bio);
- BIO_set_next(bio, NULL);
- }
+ if (!ptr)
+ return 0;
ringbuffer_destroy(&ptr->xmitBuffer);
free(ptr);
if (!transport)
return FALSE;
+ if (transport->rdg && (transport->rdg->frontBio == transport->frontBio))
+ transport->frontBio = NULL;
+
if (transport->tls)
{
tls_free(transport->tls);
BIO_read(outBIO, buffer, size);
}
- BIO_free(outBIO);
+ BIO_free_all(outBIO);
return buffer;
}
if (!ssl)
{
- BIO_free(bio);
+ BIO_free_all(bio);
return NULL;
}
}
rsa = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL);
- BIO_free(bio);
+ BIO_free_all(bio);
if (!rsa)
{
}
x509 = PEM_read_bio_X509(bio, NULL, NULL, 0);
- BIO_free(bio);
+ BIO_free_all(bio);
if (!x509)
{
if (!rc)
free(pemCert);
- BIO_free(bio);
+ BIO_free_all(bio);
return rc;
}
tls->ctx = NULL;
}
- if (tls->bio)
- {
- BIO_free(tls->bio);
- tls->bio = NULL;
- }
-
- if (tls->underlying)
- {
- BIO_free(tls->underlying);
- tls->underlying = NULL;
- }
+ /* tls->underlying is a stacked BIO under tls->bio.
+ * BIO_free_all will free recursivly. */
+ BIO_free_all(tls->bio);
+ tls->bio = NULL;
+ tls->underlying = NULL;
if (tls->PublicKey)
{
{
WLog_ERR(TAG, "BIO_new failed");
goto out_bio_read_failed;
- return -1;
}
status = BIO_set_write_buf_size(context->bioRead, SCHANNEL_CB_MAX_TOKEN);
out_read_alloc:
out_bio_pair:
out_set_write_buf_write:
- BIO_free(context->bioWrite);
+ BIO_free_all(context->bioWrite);
out_bio_write_failed:
out_set_write_buf_read:
- BIO_free(context->bioRead);
+ BIO_free_all(context->bioRead);
out_bio_read_failed:
SSL_free(context->ssl);
out_ssl_new_failed:
out_read_buffer:
out_bio_pair:
out_set_write_buf_write:
- BIO_free(context->bioWrite);
+ BIO_free_all(context->bioWrite);
out_bio_write:
out_set_write_buf_read:
- BIO_free(context->bioRead);
+ BIO_free_all(context->bioRead);
out_bio_read:
out_use_certificate:
SSL_free(context->ssl);
free(x509_str);
x509_str = NULL;
- BIO_free(bio);
+ BIO_free_all(bio);
bio = NULL;
if (context->pemFormat)
ret = 1;
out_fail:
-
- if (bio)
- BIO_free(bio);
+ BIO_free_all(bio);
if (fp)
fclose(fp);
if (fp)
fclose(fp);
- if (bio)
- BIO_free(bio);
-
+ BIO_free_all(bio);
free(x509_str);
free(filename);
free(fullpath);
if (status < 0)
{
- BIO_free(bio);
+ BIO_free_all(bio);
return -1;
}
if (!(x509_str = (BYTE*) malloc(length + 1)))
{
- BIO_free(bio);
+ BIO_free_all(bio);
return -1;
}
if (status < 0)
{
- BIO_free(bio);
+ BIO_free_all(bio);
free(x509_str);
return -1;
}
x509_str[length] = '\0';
printf("%s", x509_str);
free(x509_str);
- BIO_free(bio);
+ BIO_free_all(bio);
}
/**