Merge pull request #5930 from MathiasVP/promote-incorrect-allocation-error-out

C++: Promote `cpp/incorrect-allocation-error-handling`
This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-25 10:57:31 +02:00
committed by GitHub
8 changed files with 6 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
lgtm
* A new query (`cpp/incorrect-allocation-error-handling`) has been added. The query finds incorrect error-handling of calls to `operator new`. This query was originally [submitted as an experimental query by @ihsinme](https://github.com/github/codeql/pull/5010).

View File

@@ -21,7 +21,7 @@ void bad2(std::size_t length) noexcept {
}
}
// GOOD: the allocation failure is handled appropiately.
// GOOD: the allocation failure is handled appropriately.
void good1(std::size_t length) noexcept {
try {
int* dest = new int[length];
@@ -32,7 +32,7 @@ void good1(std::size_t length) noexcept {
}
}
// GOOD: the allocation failure is handled appropiately.
// GOOD: the allocation failure is handled appropriately.
void good2(std::size_t length) noexcept {
int* dest = new int[length];
if(!dest) {

View File

@@ -1,6 +1,6 @@
/**
* @name Incorrect allocation-error handling
* @description `operator new` throws an exception on allocation failures, while `operator new(std::nothrow)` returns a null pointer. Mixing up these two failure conditions can result in unexpected behavior.
* @description Mixing up the failure conditions of 'operator new' and 'operator new(std::nothrow)' can result in unexpected behavior.
* @kind problem
* @id cpp/incorrect-allocation-error-handling
* @problem.severity warning

View File

@@ -1 +0,0 @@
experimental/Security/CWE/CWE-570/IncorrectAllocationErrorHandling.ql

View File

@@ -0,0 +1 @@
Security/CWE/CWE-570/IncorrectAllocationErrorHandling.ql