Closed
Description
The pointer s->v.AsyncFunctionDef.args->kw_defaults is explicitly checked for NULL:
Lines 2193 to 2195 in aaad2e8
However, a few lines later, the same pointer is passed unconditionally to the has_kwonlydefaults function:
Lines 2203 to 2204 in aaad2e8
Inside has_kwonlydefaults, the kw_defaults parameter is not checked for NULL before being dereferenced:
Lines 1783 to 1787 in aaad2e8
Activity
pythongh-135302: Fix NULL pointer dereference in has_kwonlydefaults f…
JelleZijlstra commentedon Jun 9, 2025
This isn't necessary because we access kw_defaults only if kwonlyargs is nonempty.
picnixz commentedon Jun 9, 2025
@JelleZijlstra I suggested adding an assertion #135303 (comment) but I don't know if you wouldn't prefer a PR that adds assertions also elsewhere rather than just modifiying this single place.
JelleZijlstra commentedon Jun 9, 2025
I don't really have a preference. The code is fine as is; an assertion would be harmless but not help much. Feel free to merge a PR adding assertions if you feel it's useful.
picnixz commentedon Jun 9, 2025
I think it's only useful if there is a chance to call the function by mistake. If it's not the case, then let's keep the code as is (I don't know if there are other places that would benefit having an assertion)
rialbat commentedon Jun 10, 2025
Got it. Thanks for your answer. I'll close the issue and PR.