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

An apocalypse detector... #1140

Merged
merged 9 commits into from
Oct 20, 2016
Merged

An apocalypse detector... #1140

merged 9 commits into from
Oct 20, 2016

Conversation

eggrobin
Copy link
Member

... but somehow I cannot trigger it. Fixes some issues in the interface though.
Changes to the code generator: for the changes to the output see c81f490.

CHECK_NOTNULL(plugin)->HasEncounteredApocalypse(allocated_details);
*CHECK_NOTNULL(details) = allocated_details->c_str();
CHECK_NOTNULL(plugin)->HasEncounteredApocalypse(&details_string);
UniqueBytes allocated_details(details_string.size() + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very complicated. I don't think you need allocated_details at all: just copy details_string into *details.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone has to allocate something releaseable; *details may well be null.
Note that the existing code with new std::string was broken, the pointer to the string was lost and thus leaked---and then the c_str() was deallocated, which is probably UB.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

@pleroy pleroy added the LGTM label Oct 18, 2016
@eggrobin eggrobin merged commit 21187e9 into mockingbirdnest:master Oct 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants