Skip to content

Commit 70ee2b8

Browse files
committed
C++: Handle null and boolean conversions.
1 parent 15447bf commit 70ee2b8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,20 @@ module ConstructorForwarding {
12301230
)
12311231
}
12321232

1233+
private predicate nullPointerConversion(Type t) {
1234+
t instanceof Cpp::PointerType or t instanceof FunctionPointerType
1235+
}
1236+
1237+
private predicate booleanConversion(Type t) {
1238+
t instanceof Cpp::PointerType
1239+
or
1240+
t instanceof FunctionPointerType
1241+
or
1242+
t instanceof Cpp::ArrayType
1243+
or
1244+
t instanceof RoutineType
1245+
}
1246+
12331247
private predicate referenceAcceptsCategory(Cpp::ReferenceType t, ValueCategory category) {
12341248
if t instanceof Cpp::LValueReferenceType
12351249
then
@@ -1373,6 +1387,12 @@ module ConstructorForwarding {
13731387
arithmeticConversion(argType)
13741388
or
13751389
pointerConversion(argType, paramType)
1390+
or
1391+
argType instanceof NullPointerType and
1392+
nullPointerConversion(paramType)
1393+
or
1394+
booleanConversion(argType) and
1395+
paramType instanceof BoolType
13761396
)
13771397
}
13781398

0 commit comments

Comments
 (0)