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

DM-19674: Channel: check error status from astRead #51

Merged
merged 1 commit into from May 10, 2019

Conversation

PaulPrice
Copy link
Contributor

If the error status isn't checked, it can deceive us into thinking it's
coming from somewhere else.

If the error status isn't checked, it can deceive us into thinking it's
coming from somewhere else.
@@ -49,6 +49,7 @@ Channel::~Channel() {

std::shared_ptr<Object> Channel::read() {
AstObject *rawRet = reinterpret_cast<AstObject *>(astRead(getRawPtr()));
assertOK(rawRet);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it takes an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Signature says it takes up to two objects that should be deallocated if the error check fails. We should really be capturing pointers like this in a smart pointer immediately and relying on destructors to take care of them, but that definitely seems out of scope for this ticket, and it's possible there was a valid reason for not doing so here.

Copy link
Member

Choose a reason for hiding this comment

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

Weird, the others in this file don't seem to take any, but ok 😄

Copy link
Member

@TallJimbo TallJimbo left a comment

Choose a reason for hiding this comment

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

Looks good. As discussed out-of-band, let's get this on master ASAP but make sure we do follow up eventually with a test case. I wouldn't be opposed to looking for other exception throws in astshim to see if they should get the same treatment.

I'm really getting out of scope now, but if there's global error state, asserting that it's clear before doing anything would also be worth considering.

@PaulPrice PaulPrice merged commit 31169da into master May 10, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants