Skip to content

Commit a71ae2b

Browse files
committed
C++: Consistent treatment of placement new.
1 parent 492c5f3 commit a71ae2b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cpp/ql/src/Critical/NewDelete.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ predicate allocExpr(Expr alloc, string kind) {
1818
alloc.(AllocationExpr).(FunctionCall).getTarget() = target and
1919
(
2020
target.getName() = "operator new" and
21-
kind = "new"
21+
kind = "new" and
22+
// exclude placement new and custom overloads as they
23+
// may not conform to assumptions
24+
not target.getNumberOfParameters() > 1
2225
or
2326
target.getName() = "operator new[]" and
24-
kind = "new[]"
27+
kind = "new[]" and
28+
// exclude placement new and custom overloads as they
29+
// may not conform to assumptions
30+
not target.getNumberOfParameters() > 1
2531
or
2632
not target instanceof OperatorNewAllocationFunction and
2733
kind = "malloc"

0 commit comments

Comments
 (0)