Add missing cases to watch out for in lCheckAllOffSafety()
Previously, we weren't checking for member expressions that dereferenced a pointer or pointer dereference expressions--only array indexing!
This commit is contained in:
1
expr.h
1
expr.h
@@ -314,7 +314,6 @@ public:
|
|||||||
std::string identifier;
|
std::string identifier;
|
||||||
const SourcePos identifierPos;
|
const SourcePos identifierPos;
|
||||||
|
|
||||||
protected:
|
|
||||||
MemberExpr(Expr *expr, const char *identifier, SourcePos pos,
|
MemberExpr(Expr *expr, const char *identifier, SourcePos pos,
|
||||||
SourcePos identifierPos, bool derefLValue);
|
SourcePos identifierPos, bool derefLValue);
|
||||||
|
|
||||||
|
|||||||
17
stmt.cpp
17
stmt.cpp
@@ -695,6 +695,23 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All indices are in-bounds
|
// All indices are in-bounds
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberExpr *me;
|
||||||
|
if ((me = dynamic_cast<MemberExpr *>(node)) != NULL &&
|
||||||
|
me->dereferenceExpr) {
|
||||||
|
*okPtr = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DereferenceExpr *de;
|
||||||
|
if ((de = dynamic_cast<DereferenceExpr *>(node)) != NULL) {
|
||||||
|
const Type *exprType = de->expr->GetType();
|
||||||
|
if (dynamic_cast<const PointerType *>(exprType) != NULL) {
|
||||||
|
*okPtr = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user