analyzer: only use CWE-690 for unchecked return value [PR97893]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 18 Nov 2020 20:53:36 +0000 (15:53 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 18 Nov 2020 20:53:36 +0000 (15:53 -0500)
commitf3f312b535f57b5773953746f6ad0d890ce09b88
tree38172f9eeb84e79b451af0045f37e113f3b5b656
parent08028093211c1b57f33e5669f816157934ab23dd
analyzer: only use CWE-690 for unchecked return value [PR97893]

CWE-690 is only for dereferencing an unchecked return value; for
other kinds of NULL dereference, use the parent classification, CWE-476.

gcc/analyzer/ChangeLog:
PR analyzer/97893
* sm-malloc.cc (null_deref::emit): Use CWE-476 rather than
CWE-690, as this isn't due to an unchecked return value.
(null_arg::emit): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/97893
* gcc.dg/analyzer/malloc-1.c: Add CWE-690 and CWE-476 codes to
expected output.
gcc/analyzer/sm-malloc.cc
gcc/testsuite/gcc.dg/analyzer/malloc-1.c