Skip to content

SemaObjC::HandleExprPropertyRefExpr assumes getInterfaceType() will never return nullptr #134954

Open
@shafik

Description

@shafik

Static analysis has flagged, this line in SemaObjC::HandleExprPropertyRefExpr:

const ObjCInterfaceType *IFaceT = OPT->getInterfaceType();
ObjCInterfaceDecl *IFace = IFaceT->getDecl();

as possibly returning nullptr which would make the subsequent access of IFaceT->getDecl(); UB.

Based on the documentation:

/// HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an
/// objective C interface. This is a property reference expression.

and the rest of the code it seems clear that the assumption is that it will always be valid.

We could document more clearly w/ an assertion on IFaceT.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions