Skip to content

Commit 80d41d9

Browse files
committed
C++: Add false positive testcase involving assignments.
1 parent 08fa611 commit 80d41d9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-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:219:9:219:15 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:220:34:220:36 | { ... } | This catch block |

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,10 @@ void bad_new_catch_baseclass_of_bad_alloc() {
212212
int* p = new(std::nothrow) int; // BAD
213213
} catch(const std::exception&) { }
214214
}
215+
216+
void good_new_catch_exception_in_assignment() {
217+
int* p;
218+
try {
219+
p = new int; // GOOD [FALSE POSITIVE]
220+
} catch(const std::bad_alloc&) { }
221+
}

0 commit comments

Comments
 (0)