diff options
author | Pauli <pauli@openssl.org> | 2021-06-09 11:58:48 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-10 18:11:45 +1000 |
commit | 5a9dbfc58ab280ec426ed013f5aed5a5660b938a (patch) | |
tree | 40ad95d2ba8f8541bbef477f00ced6a81cfbbb9e /crypto/err/err_local.h | |
parent | 5ac6d7d21b4e896fee2eca0488915faaea196448 (diff) |
err: clear flags better when clearing errors.
An attempt to clear an error with malloced data didn't clear the flags.
Now it clears all flags except the malloced flag.
Fixes #12530
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15667)
Diffstat (limited to 'crypto/err/err_local.h')
-rw-r--r-- | crypto/err/err_local.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/err/err_local.h b/crypto/err/err_local.h index 678f92dc04..d4e19dff24 100644 --- a/crypto/err/err_local.h +++ b/crypto/err/err_local.h @@ -27,6 +27,7 @@ static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall) es->err_data_flags[i] = 0; } else if (es->err_data[i] != NULL) { es->err_data[i][0] = '\0'; + es->err_data_flags[i] = ERR_TXT_MALLOCED; } } else { es->err_data[i] = NULL; @@ -68,6 +69,8 @@ static ossl_inline void err_set_debug(ERR_STATE *es, size_t i, static ossl_inline void err_set_data(ERR_STATE *es, size_t i, void *data, size_t datasz, int flags) { + if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0) + OPENSSL_free(es->err_data[i]); es->err_data[i] = data; es->err_data_size[i] = datasz; es->err_data_flags[i] = flags; |