Skip to content

Commit 7c1720a

Browse files
committed
C++: Remove NoThrowAllocator and inline its (corrected) definition in ThrowingAllocator.
1 parent 5437bd7 commit 7c1720a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,16 @@ predicate exprMayThrow(Expr e) {
147147
)
148148
}
149149

150-
/** An allocator that will not throw an exception. */
151-
class NoThrowAllocator extends Function {
152-
NoThrowAllocator() {
150+
/** An allocator that might throw an exception. */
151+
class ThrowingAllocator extends Function {
152+
ThrowingAllocator() {
153153
exists(NewOrNewArrayExpr newExpr |
154154
newExpr.getAllocator() = this and
155-
not functionMayThrow(this)
155+
functionMayThrow(this)
156156
)
157157
}
158158
}
159159

160-
/** An allocator that might throw an exception. */
161-
class ThrowingAllocator extends Function {
162-
ThrowingAllocator() { not this instanceof NoThrowAllocator }
163-
}
164-
165160
/** The `std::bad_alloc` exception and its `bsl` variant. */
166161
class BadAllocType extends Class {
167162
BadAllocType() { this.hasGlobalOrStdOrBslName("bad_alloc") }

0 commit comments

Comments
 (0)