[3.6] bpo-31852: Fix segfault caused by using the async soft keyword by pablogsal · Pull Request #4122 · python/cpython (original) (raw)
This PR solves a segmentation fault in Python 3.6 caused by a combination of the async soft keyword and continuation lines. Steps to reproduce:
async
... File "", line 1 \ufffd\ufffdF\ufffd\ufffd ^ SyntaxError: invalid syntax async
Segmentation fault
As @Haypo mentioned in the issue you can use this file to use the issue in the tokenizer to induce a buffer overflow. This PR solves this issue as well.
The current implementation checks if the current token is ASYNC
and sets a sentient value (2
) in the tok->async_def
before looking for the token ahead (which is the step where the segfault happens). The value of tok->async_def
gets overwritten after the lookahead by the usual value (1
). As this particular issues are fixed by #1669 in the current master (3.7) this PR acts as a mere patch.