-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
…there, generator isn't.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
... 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.