cppcheck/addons/test/misra
Tim Blume b70e1df26c
fix crash while checking misra_9 when initializing a union with {{0,0}} (#5250)
This fixes a crash with following error:
```
Traceback (most recent call last):
  File "/usr/local/share/Cppcheck/addons/runaddon.py", line 8, in <module>
    runpy.run_path(addon, run_name='__main__')
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4737, in <module>
    main()
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4679, in main
    checker.parseDump(item)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4335, in parseDump
    self.executeCheck(902, self.misra_9_2, cfg)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4246, in executeCheck
    check_function(*args)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 2104, in misra_9_2
    misra_9.misra_9_x(self, data, 902)
  File "/usr/local/share/Cppcheck/addons/misra_9.py", line 414, in misra_9_x
    parser.parseInitializer(ed, eq.astOperand2)
  File "/usr/local/share/Cppcheck/addons/misra_9.py", line 320, in parseInitializer
    child = self.root.getChildByValueElement(self.ed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'getChildByValueElement'
```

A minimal example and testcase is added. 
The extra check for nextChild seems to fix it, however i did not read
the whole codebase, so maybe this creates other issues.

---------

Co-authored-by: Tim Blume <tbl@sevenstax-intern.de>
2023-08-31 09:38:03 +02:00
..
crash1.c misra: fix crash 2022-05-17 22:15:49 +02:00
crash2.c Fix #11793 (False positive: Misra addon crash for struct initialization when struct has a function pointer array) (#5190) 2023-06-25 11:37:49 +02:00
crash3.c Fix #11812 (Crash: misra addon, infinite recursion) (#5207) 2023-07-04 04:11:03 +02:00
crash4.c misra: Fix crash in misra_9x when there is unknown constant used as array size (#5229) 2023-07-10 12:25:28 +02:00
crash5.c misra: Fix crash in misra_9x when there is unknown constant used as array size (#5229) 2023-07-10 12:25:28 +02:00
crash6.c misra 9.2: do not crash when checking. string literal is allowed to initialize array member. (#5232) 2023-07-10 22:50:24 +02:00
crash7.c misra: Fix crash in misra_9.py when struct type is unknown and there is string initialization (#5233) 2023-07-11 13:40:19 +02:00
crash8.c misra: fix 9.x checking when string literals are used to initialize char arrays (#5234) 2023-07-11 17:57:55 +02:00
crash9.c dump: fix dump output for typedef info, file is <stdout> (#5236) 2023-07-12 11:21:59 +02:00
crash_misra9_parseInitializer.c fix crash while checking misra_9 when initializing a union with {{0,0}} (#5250) 2023-08-31 09:38:03 +02:00
misra-ctu-1-test.c Fixed #11734 (stylistic warnings from addons are not filtered when style is not enabled) (#5091) 2023-05-27 10:24:00 +02:00
misra-ctu-2-test.c Fixed #11734 (stylistic warnings from addons are not filtered when style is not enabled) (#5091) 2023-05-27 10:24:00 +02:00
misra-ctu-test.h Misra false positive fixes for rules 8.7 and 5.9 (#3844) 2022-02-27 19:17:48 +01:00
misra-suppressions1-test.c misra; implement rule 8.4 2021-07-10 20:10:44 +02:00
misra-suppressions2-test.c misra; fix test_rules_suppression 2021-09-17 08:23:48 +02:00
misra-test-avr8.c CI: Fix selfcheck cppcheck warnings (#5359) 2023-08-22 14:49:08 +02:00
misra-test.c Fix #11877 FP misra 10.4 On array member comparison (#5342) 2023-08-22 12:18:12 +02:00
misra-test.cpp misra: enable more checks for misra c++ 2008 checking 2022-06-07 20:55:55 +02:00
misra-test.h CI; Improved testing of misra addon 2021-07-11 17:24:14 +02:00
misra2012_rules_dummy_ascii.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
misra2012_rules_dummy_utf8.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
misra2012_rules_dummy_windows1250.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
misra_rules_dummy.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
misra_rules_empty_lines.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
misra_rules_multiple_lines.txt Loosen restrictions on MISRA rules text structure (#2157) 2019-09-09 21:43:44 +02:00
misra_rules_structure.txt Update addons structure. Make Y2038 addon works. (#2024) 2019-07-26 06:38:03 +02:00
suppressions.txt misra; fix test_rules_suppression 2021-09-17 08:23:48 +02:00