bpo-31337 Close a minor NULL dereference opportunity#3282
bpo-31337 Close a minor NULL dereference opportunity#3282warsaw wants to merge 5 commits intopython:masterfrom
Conversation
Found by Kirit Sankar Gupta.
| key = get_const_value((expr_ty)asdl_seq_GET(e->v.Dict.keys, i)); | ||
| if (key == NULL) { | ||
| Py_DECREF(keys); | ||
| return 0; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
PyErr_BadInternalCall() is the most obvious.
|
@serhiy-storchaka Thanks! Where would I see an example of Victor's runtime
checks? I didn't notice anything in local tests.
See for example lines 3566-3573 in ceval.c. And there should be similar code
in several other places.
What exception do you think we should raise? `MemoryError`, `RuntimeError`
or something else?
Note that this is a dead code! I think we shouldn't add it at all.
|
|
@serhiy-storchaka Oh, I see what your reference to "Victor's runtime checks" are. Yes, I knew about the I don't agree that this is obviously dead code. You have to reason about the control flow, and assume that |
|
Closing this in favor of bpo-33138 |
https://bugs.python.org/issue31337