Fix bugs reported by Clang analyzer#3887
Merged
chemamartinez merged 13 commits into3.11from Sep 19, 2019
Merged
Conversation
9c5a3ae to
dae4311
Compare
6 tasks
This will again show false positives in the analysis if the checker alpha.core.CastToStruct is activated. To avoid them we have to mess up the code
If this happened, a merror_exit was executed
If the function returns 0, there is no such memory leak since the memory is still referenced
05f6097 to
e5eae83
Compare
chemamartinez
suggested changes
Sep 18, 2019
26 tasks
chemamartinez
approved these changes
Sep 19, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR solves the bugs reported by Clang which can be seen in the linked issue.
The reports of dangerous castings to a struct from a non-struct type will be ignored (except for
os_net.c). The reason for this is that we need to add strange and confusing code to silent these warnings, which are controlled situations (false positives). These reports cannot be omitted by just adding the#ifndef __clang_analyzer__expression.The undesired use of the
sizeoffunction insyscheck_audit.chas been solved by using the size of the memory allocated in thecachevariable.The memory leak in
rules.chas been solved by releasing theconfig_ruleinfovariable with the program flow jumps tocleanuptag in case of error. Fixing this is not dangerous since the error case of this function end in amerror_exitcall (the program finishes), and for this reason, it didn't suppose a real memory leak.The possibly memory leak reported in
reports-config.cwas a false positive because ifos_report_configfilterfunction returns 0, the memory allocated inncatis now referenced by another variable. For some reason, Clang analyzer does not verify the function flow. To solve it, the memory allocated for thefilter_valueparameter is not allocated in the function whenarg_typeisREPORT_FILTER.Tests
Compilation without warnings in every supported platform
Source installation
Package installation
Source upgrade
Package upgrade
Memory tests for Linux