www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12691] New: std.regex.bmatch with empty string after OR


          Issue ID: 12691
           Summary: std.regex.bmatch with empty string after OR operator
                    crashes with free(): invalid pointer
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: yxcvbasdfgqwert02 gmx.de

Created attachment 1349
  --> https://issues.dlang.org/attachment.cgi?id=1349&action=edit
Source code for test case

Certain expressions/haystacks seem to trigger a memory error in

In the attached source code, the regular expression is kind-of stupid, however
it should be either treated as wrong (std.regex.regex should throw an
exception) or should work, but never crash. In the test case, the expression
"([a-z]|)" uses an empty string after the OR operator.

The crash also occurred on a more complex expression with 2 OR operators
beneath, containing something like "a||b".

Using match instead of bmatch returns the expected result: the expression
doesn't match the haystack.

Btw, I used bmatch instead of match because bmatch is way faster (see issue

May 02 2014