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 a TypeError #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix a TypeError #162

wants to merge 1 commit into from

Conversation

bendrissou
Copy link

When running LangFuzzer2 fuzzer, there is a crash:

Traceback (most recent call last):
...
    v = lf.fuzz()
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/LangFuzzer.py", line 443, in fuzz
    modified = self.gfuzz.expand_tree(tree_with_a_hole)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 982, in expand_tree
    tree = self.expand_tree_with_strategy(
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 973, in expand_tree_with_strategy
    or self.possible_expansions(tree) < limit)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 678, in possible_expansions
    return sum(self.possible_expansions(c) for c in children)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 678, in <genexpr>
    return sum(self.possible_expansions(c) for c in children)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 678, in possible_expansions
    return sum(self.possible_expansions(c) for c in children)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 678, in <genexpr>
    return sum(self.possible_expansions(c) for c in children)
  File "/usr/local/lib/python3.10/dist-packages/fuzzingbook/GrammarFuzzer.py", line 674, in possible_expansions
    (symbol, children) = node
TypeError: cannot unpack non-iterable NoneType object

The cause is the encounter of an unexpected NoneType object: node

 (symbol, children) = node
 if children is None:
     return 1

Importantly, children is checked against None, and not the node itself. Therefore, in our fix we assign None to children. And node remains always a tuple.

When running LangFuzzer2 fuzzer, there is a crash. The cause is the encounter of an unexpected NoneType object. Importantly, node's Children are checked against None, and not the node itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant