Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add values to Bson object containing a BsonRegex value #238

Closed
ReneZwanenburg opened this issue Jun 3, 2013 · 3 comments
Closed

Comments

@ReneZwanenburg
Copy link
Contributor

When adding any type of value to a Bson object which contains a BsonRegex, an AssertError is thrown.

The root cause is that the Bson raw data constructor has an assert(false) when Type == Regex (vibe.data.bson : 112).
Bson.opIndexAssign uses the Bson raw data constructor when copying its existing data to a new appender (vibe.data.bson : 464).

Some example code to demonstrate the issue:

auto bson = Bson.EmptyObject;
bson.someRegex = BsonRegex("", "");
bson.someOtherValue = ""; // Fails here
@ReneZwanenburg
Copy link
Contributor Author

I'm not sure why that assert has been placed there, but slicing m_data from 0 to after the second null terminator in the raw data constructor seems to work fine.

@ReneZwanenburg
Copy link
Contributor Author

My apologies, but I'm not familiar enough with Git and GitHub to create a pull request atm. Will have to look into that some time. Anyway, here's what vibe.data.bson : 112 can be changed into to fix the issue:

case Type.Regex: {
    auto _data = m_data;
    _data.skipCString();
    _data.skipCString();
    m_data = m_data[0 .. $ - _data.length];
} break;

@s-ludwig
Copy link
Member

s-ludwig commented Jun 4, 2013

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants