Skip to content

Regex engine throws index out of range #114626

@LGL-Ben

Description

@LGL-Ben

Description

I'm encountering an IndexOutOfRangeException when using the following regex:

string r = "(?>(-*)+?-*)$";

Reproduction Steps

Use the above regular expression with Regex.Match.
Match against any non-zero length string.
A reproduction can be found here:
https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwAIEYB0AVApgD2EwCVcBzCAGwEMwBRfABzFwGdWBLAeylZPIKYAstWABjABYAKAESYZMGVID8APikBaAFQBKRMu06AJDJ0BuIA
I removed as much from it as much as I could.

Expected behavior

The function should return without throwing an error.

Actual behavior

The function throws an IndexOutOfRangeException

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

It should be noted that I observed the same error thrown from multiple internal functions, as I removed parts of the expression to simplify it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions