From c504e9e4af6120d5467c803ac24f05a8bb1fbaa3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Jul 2015 19:27:33 +0300 Subject: Do not check for null pointers variables with vptr. --- src/analysis/expression.cpp | 17 +++++++++++++++++ src/analysis/expression.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp index 4c7fa5e..f51a432 100644 --- a/src/analysis/expression.cpp +++ b/src/analysis/expression.cpp @@ -154,6 +154,8 @@ std::string getComponentRefVariable(Node *node) return str; IndirectRefNode *indirect = static_cast(object); Node *ref = skipNop(indirect->ref); + if (ref && !isValidVar(ref->label)) + return str; if (ref == PARM_DECL) { ParmDeclNode *decl = static_cast(ref); @@ -171,6 +173,8 @@ std::string getComponentRefVariable(Node *node) } if (ref == PARM_DECL || ref == VAR_DECL) { + if (!isValidVar(field->label)) + return str; str.append(ref->label).append("->").append(field->label); } } @@ -178,6 +182,13 @@ std::string getComponentRefVariable(Node *node) return str; } +bool isValidVar(const std::string &str) +{ + if (str.size() > 6 && str.substr(0, 6) == "_vptr.") + return false; + return true; +} + std::vector getComponentRefParts(Node *node) { std::vector str; @@ -194,6 +205,8 @@ std::vector getComponentRefParts(Node *node) FieldDeclNode *fieldDecl = static_cast(field); IndirectRefNode *indirect = static_cast(object); Node *ref = skipNop(indirect->ref); + if (ref && !isValidVar(ref->label)) + return str; if (ref == PARM_DECL) { ParmDeclNode *parmDecl = static_cast(ref); @@ -219,6 +232,8 @@ std::vector getComponentRefParts(Node *node) if (arr->elementType != POINTER_TYPE) return str; } + if (!isValidVar(field->label)) + return str; str.push_back(std::string(ref->label).append("->").append(field->label)); } } @@ -244,6 +259,8 @@ std::vector getComponentRefLeftParts(Node *node) // return str; IndirectRefNode *indirect = static_cast(object); Node *ref = skipNop(indirect->ref); + if (ref && !isValidVar(ref->label)) + return str; if (ref == PARM_DECL || ref == VAR_DECL) { str.push_back(ref->label); diff --git a/src/analysis/expression.h b/src/analysis/expression.h index 602a9ae..b07f296 100644 --- a/src/analysis/expression.h +++ b/src/analysis/expression.h @@ -105,6 +105,8 @@ namespace Analysis Node *node1, Node *node2, WalkItem &wo); + + bool isValidVar(const std::string &str); } #endif // ANALYSIS_EXPRESSION_H -- cgit v1.2.3-70-g09d2