Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ThrowingAllocator extends Function {
// 3. the allocator isn't marked with `throw()` or `noexcept`.
not exists(this.getBlock()) and
not exists(Parameter p | p = this.getAParameter() |
p.getUnspecifiedType() instanceof NoThrowType
p.getUnspecifiedType().stripType() instanceof NoThrowType
) and
not this.isNoExcept() and
not this.isNoThrow()
Expand Down
10 changes: 9 additions & 1 deletion cpp/ql/test/query-tests/Security/CWE/CWE-570/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,12 @@ void good_new_catch_exception_in_conversion() {
try {
long* p = (long*) new int; // GOOD
} catch(const std::bad_alloc&) { }
}
}

// The 'n' parameter is just to distinquish it from the overload further up in this file.
void *operator new(std::size_t, int n, const std::nothrow_t &);

void test_operator_new_without_exception_spec() {
int* p = new(42, std::nothrow) int; // GOOD
if(p == nullptr) {}
}