This is a logical bug.
When occured a error, apn_free() will be called to clear something(reference the sample), then apn_close() called by apn_free().
Because after calling SSL_free(ctx->ssl), the ctx->ssl is not NULL, then SSL_free(ctx->ssl) will be called again.
And then will be crash.
So, SSL_free(ctx->ssl) can't be called here.
This is a logical bug. When occured a error, apn_free() will be called to clear something(reference the sample), then apn_close() called by apn_free(). Because after calling SSL_free(ctx->ssl), the ctx->ssl is not NULL, then SSL_free(ctx->ssl) will be called again. And then will be crash. So, SSL_free(ctx->ssl) can't be called here.