update comments and check error case

This commit is contained in:
Jacob Barthelmeh
2022-11-22 11:22:38 -07:00
parent 143dac64a3
commit b6ae17804a
2 changed files with 19 additions and 5 deletions

View File

@ -17076,10 +17076,22 @@ cleanup:
} }
else { else {
int idx = wc_GetCurrentIdx(); int idx = wc_GetCurrentIdx();
if (idx > 0) { if (idx < 0) {
idx = idx -1; WOLFSSL_MSG("Error with getting current index!");
ret = BAD_STATE_E;
WOLFSSL_LEAVE("wolfSSL_ERR_get_error", ret);
/* panic and try to clear out nodes and reset queue state */
wc_ClearErrorNodes();
}
else if (idx > 0) {
idx -= 1;
wc_RemoveErrorNode(idx);
}
else {
/* if current idx is 0 then the queue only had one node */
wc_RemoveErrorNode(idx);
} }
wc_RemoveErrorNode(idx);
} }
return ret; return ret;

View File

@ -812,8 +812,10 @@ int wc_AddErrorNode(int error, int line, char* buf, char* file)
#endif #endif
} }
/* returns the current index into the queue, can be greater than zero in cases /* returns the current index into the queue, which is the node that
* where wc_PullErrorNode() has been callded. */ * wc_current_node is pointing to. It can be greater than zero in cases
* where wc_PullErrorNode() has been called without the node having been
* removed. */
int wc_GetCurrentIdx() int wc_GetCurrentIdx()
{ {
int ret = 0; int ret = 0;