In the following example, jsonReader.ReadBsonType() will never return.
using (var jsonReader = new JsonReader("/")) { Console.WriteLine("before"); jsonReader.ReadBsonType(); Console.WriteLine("after"); }
The problem resides within JsonScanner.GetRegularExpressionToken() as it doesn't account for a -1 return code from buffer.Read() during the RegularExpressionState.InPattern state. GetRegularExpressionToken() will spin indefinitely without yielding.
This can be fixed with a single line:
case RegularExpressionState.InPattern: switch (c) { case '/': state = RegularExpressionState.InOptions; break; case '\\': state = RegularExpressionState.InEscapeSequence; break; // This is the fix case -1: state = RegularExpressionState.Invalid; break; default: state = RegularExpressionState.InPattern; break; } break;
I will be submitting a pull request soon.
- links to