diff options
author | Richard Levitte <levitte@openssl.org> | 2017-08-05 21:47:00 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-08-15 14:26:12 +0200 |
commit | e1a4ff7678ef8fd2d67416f84a7408e826c7dccc (patch) | |
tree | 52aedb8e4dcdc1e81efc3628514af1fd36e18dfb /crypto | |
parent | 9237173eeba0a99de0d7a50f7b4a6149e983f866 (diff) |
Add ERR_clear_last_mark()
This allows callers to set a mark, and then clear it without removing
the errors. Useful in case an error is encountered that should be
returned up the call stack.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4094)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/err/err.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c index 9db3530330..07911e25b2 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -812,3 +812,26 @@ int ERR_pop_to_mark(void) es->err_flags[es->top] &= ~ERR_FLAG_MARK; return 1; } + +int ERR_clear_last_mark(void) +{ + ERR_STATE *es; + int top; + + es = ERR_get_state(); + if (es == NULL) + return 0; + + top = es->top; + while (es->bottom != top + && (es->err_flags[top] & ERR_FLAG_MARK) == 0) { + top -= 1; + if (top == -1) + top = ERR_NUM_ERRORS - 1; + } + + if (es->bottom == top) + return 0; + es->err_flags[top] &= ~ERR_FLAG_MARK; + return 1; +} |