SSL: fixed potential leak on memory allocation errors.
If ngx_pool_cleanup_add() fails, we have to clean just created SSL context
manually, thus appropriate call added.
Additionally, ngx_pool_cleanup_add() moved closer to ngx_ssl_create() in
the ngx_http_ssl_module, to make sure there are no leaks due to intermediate
code.
Maxim Dounin
3 years ago
699 | 699 |
return NGX_CONF_ERROR;
|
700 | 700 |
}
|
701 | 701 |
|
|
702 |
cln = ngx_pool_cleanup_add(cf->pool, 0);
|
|
703 |
if (cln == NULL) {
|
|
704 |
ngx_ssl_cleanup_ctx(&conf->ssl);
|
|
705 |
return NGX_CONF_ERROR;
|
|
706 |
}
|
|
707 |
|
|
708 |
cln->handler = ngx_ssl_cleanup_ctx;
|
|
709 |
cln->data = &conf->ssl;
|
|
710 |
|
702 | 711 |
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
|
703 | 712 |
|
704 | 713 |
if (SSL_CTX_set_tlsext_servername_callback(conf->ssl.ctx,
|
|
721 | 730 |
SSL_CTX_set_next_protos_advertised_cb(conf->ssl.ctx,
|
722 | 731 |
ngx_http_ssl_npn_advertised, NULL);
|
723 | 732 |
#endif
|
724 | |
|
725 | |
cln = ngx_pool_cleanup_add(cf->pool, 0);
|
726 | |
if (cln == NULL) {
|
727 | |
return NGX_CONF_ERROR;
|
728 | |
}
|
729 | |
|
730 | |
cln->handler = ngx_ssl_cleanup_ctx;
|
731 | |
cln->data = &conf->ssl;
|
732 | 733 |
|
733 | 734 |
if (ngx_http_ssl_compile_certificates(cf, conf) != NGX_OK) {
|
734 | 735 |
return NGX_CONF_ERROR;
|