Make sure we free the stack of names we allocated in an error path.
Found by the reproducible error patch in #21668
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/21796)
end = sk_OPENSSL_CSTRING_num(encoder_data.names);
if (end > 0) {
encoder_data.id_names = OPENSSL_malloc(end * sizeof(int));
- if (encoder_data.id_names == NULL)
+ if (encoder_data.id_names == NULL) {
+ sk_OPENSSL_CSTRING_free(keymgmt_data.names);
goto err;
+ }
for (i = 0; i < end; ++i) {
const char *name = sk_OPENSSL_CSTRING_value(keymgmt_data.names, i);