Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes with large positive and negative list multipliers #2596

Merged

Conversation

correctmost
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

#2523 is causing coverage builds to fail on OSS-Fuzz (#2511 (comment))

Closes #2521
Closes #2523

References

Previous fix in this area: #2228

Python docs on list multiplication:

Values of n less than 0 are treated as 0 (which yields an empty sequence of the same type as s).
-- https://docs.python.org/3.14/library/stdtypes.html#sequence-types-list-tuple-range

if value <= 0:
node.elts = []
return node
if len(self.elts) * value > 1e8:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are cases where the length of filtered_elts could be less than the length of self.elts.

I wasn't sure if the length check should happen before or after filtering, given that the length max is already pretty large.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 93.19%. Comparing base (ba7df4a) to head (de82852).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2596   +/-   ##
=======================================
  Coverage   93.19%   93.19%           
=======================================
  Files          93       93           
  Lines       11052    11055    +3     
=======================================
+ Hits        10300    10303    +3     
  Misses        752      752           
Flag Coverage Ξ”
linux 93.08% <100.00%> (+<0.01%) ⬆️
pypy 93.19% <100.00%> (+<0.01%) ⬆️
windows 93.17% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Ξ”
astroid/protocols.py 89.85% <100.00%> (+0.07%) ⬆️

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DanielNoord DanielNoord merged commit dfe1ccc into pylint-dev:main Oct 2, 2024
22 checks passed
@correctmost correctmost deleted the cm/fix-multiply-seq-crashes branch October 2, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MemoryError in _multiply_seq_by_int when constructing large list OverflowError in _multiply_seq_by_int
3 participants