Skip to content

bpo-31337 Close a minor NULL dereference opportunity#3282

Closed
warsaw wants to merge 5 commits intopython:masterfrom
warsaw:compile-null-ptr
Closed

bpo-31337 Close a minor NULL dereference opportunity#3282
warsaw wants to merge 5 commits intopython:masterfrom
warsaw:compile-null-ptr

Conversation

@warsaw
Copy link
Copy Markdown
Member

@warsaw warsaw commented Sep 4, 2017

@warsaw warsaw changed the title Close a minor NULL dereference opportunity bpo-31337 Close a minor NULL dereference opportunity Sep 4, 2017
Comment thread Python/compile.c
key = get_const_value((expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
if (key == NULL) {
Py_DECREF(keys);
return 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this case an error is returned, but no exception is set. This looks like a bug to me. We have fixed a number of similar bugs recent times (thanks to Victor's runtime checks).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@serhiy-storchaka Thanks! Where would I see an example of Victor's runtime checks? I didn't notice anything in local tests.

What exception do you think we should raise? MemoryError, RuntimeError or something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

PyErr_BadInternalCall() is the most obvious.

@serhiy-storchaka
Copy link
Copy Markdown
Member

serhiy-storchaka commented Sep 5, 2017 via email

@warsaw
Copy link
Copy Markdown
Member Author

warsaw commented Sep 5, 2017

@serhiy-storchaka Oh, I see what your reference to "Victor's runtime checks" are. Yes, I knew about the !PyErr_Occurred() check, but not the reference.

I don't agree that this is obviously dead code. You have to reason about the control flow, and assume that -DNDEBUG was not given, and that nothing changes to subtle break the assumptions in this code. With additional feedback, I am however willing to forego applying this in favor of a more comprehensive fix for bpo-31338.

@warsaw
Copy link
Copy Markdown
Member Author

warsaw commented Sep 6, 2017

Closing this in favor of bpo-33138

@warsaw warsaw closed this Sep 6, 2017
@warsaw warsaw deleted the compile-null-ptr branch September 6, 2017 00:43
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.

5 participants