Skip to content

Commit b33adb8

Browse files
authored
Merge pull request github#5930 from MathiasVP/promote-incorrect-allocation-error-out
C++: Promote `cpp/incorrect-allocation-error-handling`
2 parents 7ac04a8 + eb244c0 commit b33adb8

File tree

8 files changed

+6
-4
lines changed

8 files changed

+6
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm
2+
* 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).

cpp/ql/src/experimental/Security/CWE/CWE-570/IncorrectAllocationErrorHandling.cpp renamed to cpp/ql/src/Security/CWE/CWE-570/IncorrectAllocationErrorHandling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void bad2(std::size_t length) noexcept {
2121
}
2222
}
2323

24-
// GOOD: the allocation failure is handled appropiately.
24+
// GOOD: the allocation failure is handled appropriately.
2525
void good1(std::size_t length) noexcept {
2626
try {
2727
int* dest = new int[length];
@@ -32,7 +32,7 @@ void good1(std::size_t length) noexcept {
3232
}
3333
}
3434

35-
// GOOD: the allocation failure is handled appropiately.
35+
// GOOD: the allocation failure is handled appropriately.
3636
void good2(std::size_t length) noexcept {
3737
int* dest = new int[length];
3838
if(!dest) {

cpp/ql/src/experimental/Security/CWE/CWE-570/IncorrectAllocationErrorHandling.ql renamed to cpp/ql/src/Security/CWE/CWE-570/IncorrectAllocationErrorHandling.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Incorrect allocation-error handling
3-
* @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.
3+
* @description Mixing up the failure conditions of 'operator new' and 'operator new(std::nothrow)' can result in unexpected behavior.
44
* @kind problem
55
* @id cpp/incorrect-allocation-error-handling
66
* @problem.severity warning

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

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE/CWE-570/IncorrectAllocationErrorHandling.ql

0 commit comments

Comments
 (0)