Files
codeql/cpp/ql/src/Microsoft/CallWithNullSAL.ql
Jonas Jensen 4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00

23 lines
663 B
Plaintext

/**
* @name SAL requires non-null argument
* @description When null is passed to a function that is SAL-annotated to
* forbid this, undefined behavior may result.
* @kind problem
* @id cpp/call-with-null-sal
* @problem.severity warning
* @tags reliability
*/
import cpp
import SAL
from Parameter p, Call c, Expr arg
where
any(SALNotNull a).getDeclaration() = p and
c.getTarget() = p.getFunction() and
arg = c.getArgument(p.getIndex()) and
nullValue(arg)
select arg,
"Argument (" + arg.toString() + ") for parameter $@ in call to " + c.getTarget().getName() +
" may be null, but a SAL annotation forbids this.", p, p.getName()