Skip to content

Commit 12d5227

Browse files
committed
C++: Fix queries I forgot after merging github/codeql#20485 (part 2). Notice that this leaves a missing result because the guard condition logic is now interprocedural.
1 parent 8086875 commit 12d5227

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cpp/cert/src/rules/MEM52-CPP/DetectAndHandleMemoryAllocationErrors.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ module NoThrowNewErrorCheckConfig implements DataFlow::ConfigSig {
8484
source.asExpr() instanceof NotWrappedNoThrowAllocExpr
8585
}
8686

87-
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(GuardCondition gc).getAChild*() }
87+
predicate isSink(DataFlow::Node sink) {
88+
sink.asExpr().(GuardCondition).valueControlsEdge(_, _, _)
89+
}
8890
}
8991

9092
module NoThrowNewErrorCheckFlow = DataFlow::Global<NoThrowNewErrorCheckConfig>;

cpp/cert/test/rules/MEM52-CPP/DetectAndHandleMemoryAllocationErrors.expected

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ WARNING: module 'DataFlow' has been deprecated and may be removed in future (Det
33
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:82,46-54)
44
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:83,22-30)
55
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:87,20-28)
6-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:90,35-43)
7-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:95,38-46)
6+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:92,35-43)
7+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:97,38-46)
88
| test.cpp:24:7:24:34 | new | nothrow new allocation of $@ returns here without a subsequent check to see whether the pointer is valid. | test.cpp:24:7:24:34 | new | StructA * |
9-
| test.cpp:40:17:40:38 | call to allocate_without_check | nothrow new allocation of $@ returns here without a subsequent check to see whether the pointer is valid. | test.cpp:35:17:35:44 | new | StructA * |

0 commit comments

Comments
 (0)