Skip to content

Commit ea9b0f4

Browse files
authored
Merge branch 'main' into OutOfBounds
2 parents 03c17ae + d25e575 commit ea9b0f4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

c/misra/src/rules/RULE-7-4/StringLiteralAssignedToNonConstChar.ql

+9-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ class WideCharPointerType extends PointerType {
2020
override string getAPrimaryQlClass() { result = "WideCharPointerType" }
2121
}
2222

23-
class GenericCharPointerType extends PointerType {
23+
class GenericCharPointerType extends Type {
2424
GenericCharPointerType() {
25-
/* This type resolves to wchar_t* (which is in turn a typedef depending on its implementation) */
26-
this.resolveTypedefs*() instanceof WideCharPointerType
25+
// A wide char pointer type
26+
this instanceof WideCharPointerType
2727
or
28-
/* This type eventually resolves to char* */
29-
this.resolveTypedefs*() instanceof CharPointerType
28+
// A char pointer type
29+
this.getUnspecifiedType() instanceof CharPointerType
30+
or
31+
// A typedef to any such type.
32+
// Note: wchar_t is usually a typedef, so we cannot just use getUnspecifiedType() here.
33+
this.(TypedefType).getBaseType() instanceof GenericCharPointerType
3034
}
3135
}
3236

0 commit comments

Comments
 (0)