Menu

cppcheck: false positive

2019-05-09
2019-06-11
  • Paul Aitken

    Paul Aitken - 2019-05-09

    cppcheck reports OOB access on the attached file:

    $ cppcheck falsepositive.c
    Checking falsepositive.c ...
    [falsepositive.c:17]: (error) Array 'words[100]' accessed at index 9998, which is out of bounds.

    Cppcheck 1.88 dev (at eade2bb2c).

     
  • Daniel Marjamäki

     
  • Ken-Patrick Lehrmann

    I believe this is due to aa05bf0f1659bffc23a458d461b0afc1e181e59e.
    When execute-ing the && of

        (i < num_words) && (f < MAX_LINE_WORDS - 1)
    

    the lhs returns an error (because we don't have the value for num_words), and then the error is swallowed as the rhs is processed without error.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.