Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/ql/src/Critical/LargeParameter.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ where f.getAParameter() = p
and t.getSize() = size
and size > 64
and not t.getUnderlyingType() instanceof ArrayType
and not f instanceof CopyAssignmentOperator
select
p, "This parameter of type $@ is " + size.toString() + " bytes - consider passing a pointer/reference instead.",
t, t.toString()
8 changes: 8 additions & 0 deletions cpp/ql/test/query-tests/Critical/LargeParameter/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ void myFunction2(mySmallStruct *a, myLargeStruct *b) // GOOD
void myFunction3(mySmallStruct &a, myLargeStruct &b) // GOOD
{
}

struct CustomAssignmentOp {
// GOOD: it's an accepted pattern to implement copy assignment via copy and
// swap. This delegates the resource management involved in copying to the
// copy constructor so that logic only has to be written once.
CustomAssignmentOp &operator=(CustomAssignmentOp rhs);
char data[4096];
};