-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDoNotModifyObjectsWithTemporaryLifetime.ql
More file actions
31 lines (29 loc) · 1.22 KB
/
DoNotModifyObjectsWithTemporaryLifetime.ql
File metadata and controls
31 lines (29 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @id c/cert/do-not-modify-objects-with-temporary-lifetime
* @name EXP35-C: Do not modify objects with temporary lifetime
* @description Attempting to modify an object with temporary lifetime results in undefined
* behavior.
* @kind problem
* @precision high
* @problem.severity error
* @tags external/cert/id/exp35-c
* correctness
* external/cert/severity/low
* external/cert/likelihood/probable
* external/cert/remediation-cost/medium
* external/cert/priority/p4
* external/cert/level/l3
* coding-standards/baseline/safety
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
import codingstandards.c.Objects
// Note: Undefined behavior is possible regardless of whether the accessed field from the returned
// struct is an array or a scalar (i.e. arithmetic and pointer types) member, according to the standard.
from FieldAccess fa, TemporaryObjectIdentity tempObject
where
not isExcluded(fa, InvalidMemory2Package::doNotModifyObjectsWithTemporaryLifetimeQuery()) and
fa.getQualifier().getUnconverted() = tempObject
select fa, "Field access on $@ qualifier occurs after its temporary object lifetime.", tempObject,
"temporary object"