diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-09-04-09-51-53.bpo-31337.CSt-e_.rst b/Misc/NEWS.d/next/Core and Builtins/2017-09-04-09-51-53.bpo-31337.CSt-e_.rst new file mode 100644 index 000000000000000..54564b8b3a6e95f --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-09-04-09-51-53.bpo-31337.CSt-e_.rst @@ -0,0 +1,2 @@ +Close a minor NULL dereference opportunity in compile.c. Found by Kirit +Sankar Gupta. diff --git a/Python/compile.c b/Python/compile.c index e547c2fd591c498..c6f5333c64ad275 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3360,6 +3360,11 @@ compiler_subdict(struct compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end } for (i = begin; i < end; i++) { key = get_const_value((expr_ty)asdl_seq_GET(e->v.Dict.keys, i)); + if (key == NULL) { + Py_DECREF(keys); + PyErr_BadInternalCall(); + return 0; + } Py_INCREF(key); PyTuple_SET_ITEM(keys, i - begin, key); }