Skip to content

Commit

Permalink
Merge pull request #1228 from jumormt/10.16.2
Browse files Browse the repository at this point in the history
fix potential null dereference
  • Loading branch information
yuleisui authored Oct 17, 2023
2 parents aabbd9c + 4083994 commit dcaa89a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions svf/include/Graphs/CFBasicBlockG.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class CFBasicBlockEdge : public GenericCFBasicBlockEdgeTy

virtual const std::string toString() const
{
return _icfgEdge->toString();
std::string str;
std::stringstream rawstr(str);
rawstr << "CFBBGEdge: [CFBBGNode" << getDstID() << " <-- CFBBGNode" << getSrcID() << "]\t";
return rawstr.str();
}

inline const ICFGEdge *getICFGEdge() const
Expand Down Expand Up @@ -578,13 +581,16 @@ struct DOTGraphTraits<SVF::CFBasicBlockGraph *> : public DOTGraphTraits<SVF::SVF
{
CFBasicBlockEdge* edge = *(EI.getCurrent());
assert(edge && "No edge found!!");
if (SVFUtil::isa<CallCFGEdge>(edge->getICFGEdge()))
return "style=solid,color=red";
else if (SVFUtil::isa<RetCFGEdge>(edge->getICFGEdge()))
return "style=solid,color=blue";
else
if (edge->getICFGEdge()) {
if (SVFUtil::isa<CallCFGEdge>(edge->getICFGEdge())){
return "style=solid,color=red";}
else if (SVFUtil::isa<RetCFGEdge>(edge->getICFGEdge()))
return "style=solid,color=blue";
else
return "style=solid";
} else {
return "style=solid";
return "";
}
}

template<class EdgeIter>
Expand All @@ -595,11 +601,12 @@ struct DOTGraphTraits<SVF::CFBasicBlockGraph *> : public DOTGraphTraits<SVF::SVF

std::string str;
std::stringstream rawstr(str);
if (const CallCFGEdge* dirCall = SVFUtil::dyn_cast<CallCFGEdge>(edge->getICFGEdge()))
rawstr << dirCall->getCallSite();
else if (const RetCFGEdge* dirRet = SVFUtil::dyn_cast<RetCFGEdge>(edge->getICFGEdge()))
rawstr << dirRet->getCallSite();

if (edge->getICFGEdge()) {
if (const CallCFGEdge* dirCall = SVFUtil::dyn_cast<CallCFGEdge>(edge->getICFGEdge()))
rawstr << dirCall->getCallSite();
else if (const RetCFGEdge* dirRet = SVFUtil::dyn_cast<RetCFGEdge>(edge->getICFGEdge()))
rawstr << dirRet->getCallSite();
}
return rawstr.str();
}
};
Expand Down

0 comments on commit dcaa89a

Please sign in to comment.