Checking with Cppcheck static analyzer

• Jan 17, 2018 - 11:10

Following the results and the possible bugs found by the analysis ( https://musescore.org/en/node/255156 ) of PVS-Studio team [ and promptly corrected by MuseScore community; many thanks to Jojo-Schmitz :-) ], I ran Cppcheck ( http://cppcheck.sourceforge.net/ ) on master.
It gives a lot of messages, of different "severity". I think it found some possible bugs, but it is difficult to sort out "true" bug from "almost impossible corner case" bug from "false positive".

For what concerns the "errors" severity level, there are some in the thirdparty dependencies. I don't know what is the policy concerning patching thirdparty embedded code (which may also already be corrected upstream by their respective development teams).
The "errors" not in the thirdparty folder are:
- Uninitialized variable "bl" here: https://github.com/musescore/MuseScore/blob/5d1b3549d5b5075e45d07ea54e7…
I think this could be a true bug, since "bl" defined in the scope should hide the "bl" which is the argument of undoChangeBarLineType function and thus bl->score() could be undefined behavior.
- Uninitialized struct member "d.metricalLevelForLen" here: https://github.com/musescore/MuseScore/blob/5d1b3549d5b5075e45d07ea54e7…
I don't know if this member is set at a later time: I know nothing of the importmidi section.
- Memory leak: "chord" here: https://github.com/musescore/MuseScore/blob/5d1b3549d5b5075e45d07ea54e7…
This is a true memory leak of https://github.com/musescore/MuseScore/blob/5d1b3549d5b5075e45d07ea54e7…
but it happens only inside a test and does not do any actual harm, so we could live with it.

I will try to identify other possible bugs from the Cppcheck analysis output.


Comments

And here is the xml result of Cppcheck (the file can be imported by Cppcheck itself for visualization and filtering options).
It refers to master at commit 1e56312317

Attachment Size
MS3_0.7z 64.01 KB

Do you still have an unanswered question? Please log in first to post your question.