mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
C++: should only match those functions that has the same number of parameters as the call has arguments.
This commit is contained in:
@@ -22,7 +22,13 @@ Function viableCallable(CallInstruction call) {
|
||||
)
|
||||
or
|
||||
// Virtual dispatch
|
||||
result = call.(VirtualDispatch::DataSensitiveCall).resolve()
|
||||
result = call.(VirtualDispatch::DataSensitiveCall).resolve() and
|
||||
(
|
||||
call.getNumberOfArguments() <= result.getEffectiveNumberOfParameters() and
|
||||
call.getNumberOfArguments() >= result.getEffectiveNumberOfParameters()
|
||||
or
|
||||
result.isVarargs()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
|
||||
final Instruction getPositionalArgument(int index) {
|
||||
result = getPositionalArgumentOperand(index).getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of arguments of the call, including the `this` pointer, if any.
|
||||
*/
|
||||
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user