patch 8.2.2163: crash when discarded exception is the current exception

Problem:    Crash when discarded exception is the current exception.
Solution:   Compare the execption with current_exception. (closes #7499)
This commit is contained in:
Bram Moolenaar
2020-12-19 17:55:54 +01:00
parent 03290b8444
commit 13656f02e4
2 changed files with 6 additions and 5 deletions

View File

@ -606,6 +606,8 @@ discard_exception(except_T *excp, int was_finished)
{ {
char_u *saved_IObuff; char_u *saved_IObuff;
if (current_exception == excp)
current_exception = NULL;
if (excp == NULL) if (excp == NULL)
{ {
internal_error("discard_exception()"); internal_error("discard_exception()");
@ -654,10 +656,7 @@ discard_exception(except_T *excp, int was_finished)
discard_current_exception(void) discard_current_exception(void)
{ {
if (current_exception != NULL) if (current_exception != NULL)
{
discard_exception(current_exception, FALSE); discard_exception(current_exception, FALSE);
current_exception = NULL;
}
did_throw = FALSE; did_throw = FALSE;
need_rethrow = FALSE; need_rethrow = FALSE;
} }
@ -2284,8 +2283,8 @@ cleanup_conditionals(
// Cancel the pending exception. This is in the // Cancel the pending exception. This is in the
// finally clause, so that the stack of the // finally clause, so that the stack of the
// caught exceptions is not involved. // caught exceptions is not involved.
discard_exception((except_T *) discard_exception(
cstack->cs_exception[idx], (except_T *)cstack->cs_exception[idx],
FALSE); FALSE);
} }
else else

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2163,
/**/ /**/
2162, 2162,
/**/ /**/