Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and agreed to irrevocably license their contributions under the Duktape
* Luis de Bethencourt (https://github.com/luisbg)
* Ian Whyman (https://github.com/v00d00)
* Rick Sayre (https://github.com/whorfin)
* Craig Edwards (https://github.com/braindigitalis)
* Craig Leres (https://github.com/leres)
* Maurici Abad (https://github.com/mauriciabad)
* Nancy Li (https://github.com/NancyLi1013)
Expand Down
16 changes: 16 additions & 0 deletions src-input/duk_regexp_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const
}
re_ctx->steps_count++;

#if defined(DUK_USE_EXEC_TIMEOUT_CHECK)
/* Ensure that timeouts still operate while parsing a regular expression.
* without this in place a large DUK_RE_EXECUTE_STEPS value will lock up the
* parser for many seconds, even if the user is trying to enforce a much lower
* time limit using an interrupt.
*/
if (DUK_USE_EXEC_TIMEOUT_CHECK(re_ctx->thr->heap->heap_udata)) {
DUK_D(DUK_DPRINT("execution timeout within regexp parsing, throwing a RangeError"));
re_ctx->thr->interrupt_init = 0;
re_ctx->thr->interrupt_counter = 0;
DUK_HEAP_CLEAR_INTERRUPT_RUNNING(re_ctx->thr->heap);
DUK_ERROR_RANGE(re_ctx->thr, "execution timeout");
DUK_WO_NORETURN(return NULL;);
}
#endif /* DUK_USE_EXEC_TIMEOUT_CHECK */

/* Opcodes are at most 7 bits now so they encode to one byte. If this
* were not the case or 'pc' is invalid here (due to a bug etc) we'll
* still fail safely through the switch default case.
Expand Down