mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Merge pull request #6471 from MathiasVP/fix-fp-in-incorrect-allocation-error-handling
C++: Fix false-positive in 'cpp/incorrect-allocation-error-handling'
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user