Skip to content

Commit d9f0911

Browse files
authored
Merge pull request #473 from jketema/flowstate-fix
Use an IPA type for flow states
2 parents bce37ac + 8d026b0 commit d9f0911

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

c/cert/src/rules/EXP39-C/DoNotAccessVariableViaPointerOfIncompatibleType.ql

+11-15
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,24 @@ class ReallocationFunction extends AllocationFunction {
4242
ReallocationFunction() { exists(this.getReallocPtrArg()) }
4343
}
4444

45-
/**
46-
* A data-flow state for a pointer which has not been reallocated.
47-
*/
48-
class IndirectCastDefaultFlowState extends DataFlow::FlowState {
49-
IndirectCastDefaultFlowState() { this = "IndirectCastDefaultFlowState" }
50-
}
51-
52-
/**
53-
* A data-flow state for a pointer which has been reallocated but
54-
* has not yet been zeroed with a memset call.
55-
*/
56-
class IndirectCastReallocatedFlowState extends DataFlow::FlowState {
57-
IndirectCastReallocatedFlowState() { this = "IndirectCastReallocatedFlowState" }
58-
}
45+
newtype IndirectCastFlowState =
46+
/**
47+
* A data-flow state for a pointer which has not been reallocated.
48+
*/
49+
IndirectCastDefaultFlowState() or
50+
/**
51+
* A data-flow state for a pointer which has been reallocated but
52+
* has not yet been zeroed with a memset call.
53+
*/
54+
IndirectCastReallocatedFlowState()
5955

6056
/**
6157
* A data-flow configuration to track the flow from cast expressions to either
6258
* other cast expressions or to dereferences of pointers reallocated with a call
6359
* to `realloc` but not cleared via a function call to `memset`.
6460
*/
6561
module IndirectCastConfig implements DataFlow::StateConfigSig {
66-
class FlowState = DataFlow::FlowState;
62+
class FlowState = IndirectCastFlowState;
6763

6864
predicate isSource(DataFlow::Node source, FlowState state) {
6965
state instanceof IndirectCastDefaultFlowState and

0 commit comments

Comments
 (0)