diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-08-21 09:35:30 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-08-21 09:43:27 -0400 |
commit | 3703bae58b53efec3314bc07b9de157049ad8b70 (patch) | |
tree | 58d7b2b6d1bbd8f56a7576bd5971a0051db52ef8 /coverage/phystokens.py | |
parent | 816acad2de49e82e3903f4736d611e715a0b5780 (diff) | |
download | python-coveragepy-git-3703bae58b53efec3314bc07b9de157049ad8b70.tar.gz |
fix: don't cache a failed parse
Found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50381
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r-- | coverage/phystokens.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py index 7184f160..c6dc1e0a 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -173,7 +173,11 @@ class CachedTokenizer: if text != self.last_text: self.last_text = text readline = iter(text.splitlines(True)).__next__ - self.last_tokens = list(tokenize.generate_tokens(readline)) + try: + self.last_tokens = list(tokenize.generate_tokens(readline)) + except: + self.last_text = None + raise return self.last_tokens # Create our generate_tokens cache as a callable replacement function. |