mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
C++: Fix case where implicit downcasts were not detected when using reference
This commit is contained in:
@@ -13,10 +13,16 @@
|
||||
|
||||
import cpp
|
||||
|
||||
from BitField fi, VariableAccess va
|
||||
from BitField fi, VariableAccess va, Type fct
|
||||
where
|
||||
fi.getNumBits() > va.getFullyConverted().getType().getSize() * 8 and
|
||||
va.getExplicitlyConverted().getType().getSize() > va.getFullyConverted().getType().getSize() and
|
||||
(
|
||||
if va.getFullyConverted().getType() instanceof ReferenceType
|
||||
then fct = va.getFullyConverted().getType().(ReferenceType).getBaseType()
|
||||
else fct = va.getFullyConverted().getType()
|
||||
) and
|
||||
fi.getNumBits() > fct.getSize() * 8 and
|
||||
va.getExplicitlyConverted().getType().getSize() > fct.getSize() and
|
||||
va.getTarget() = fi and
|
||||
not va.getActualType() instanceof BoolType
|
||||
not fct.getUnspecifiedType() instanceof BoolType and
|
||||
any()
|
||||
select va, "Implicit downcast of bitfield $@", fi, fi.toString()
|
||||
|
||||
Reference in New Issue
Block a user