Skip to content

Commit 7adb7b6

Browse files
committed
C++: Add false positive testcase involving conversions.
1 parent 88e6cba commit 7adb7b6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-570/semmle/tests/IncorrectAllocationErrorHandling.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
| test.cpp:151:9:151:24 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:152:15:152:18 | { ... } | This catch block |
1717
| test.cpp:199:15:199:35 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:201:16:201:19 | { ... } | This catch block |
1818
| test.cpp:212:14:212:34 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:213:34:213:36 | { ... } | This catch block |
19+
| test.cpp:225:23:225:29 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:226:34:226:36 | { ... } | This catch block |

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-570/semmle/tests/test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,10 @@ void good_new_catch_exception_in_assignment() {
218218
try {
219219
p = new int; // GOOD
220220
} catch(const std::bad_alloc&) { }
221+
}
222+
223+
void good_new_catch_exception_in_conversion() {
224+
try {
225+
long* p = (long*) new int; // GOOD [FALSE POSITIVE]
226+
} catch(const std::bad_alloc&) { }
221227
}

0 commit comments

Comments
 (0)