Skip to content

Commit dcaa89a

Browse files
authored
Merge pull request #1228 from jumormt/10.16.2
fix potential null dereference
2 parents aabbd9c + 4083994 commit dcaa89a

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

svf/include/Graphs/CFBasicBlockG.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ class CFBasicBlockEdge : public GenericCFBasicBlockEdgeTy
8484

8585
virtual const std::string toString() const
8686
{
87-
return _icfgEdge->toString();
87+
std::string str;
88+
std::stringstream rawstr(str);
89+
rawstr << "CFBBGEdge: [CFBBGNode" << getDstID() << " <-- CFBBGNode" << getSrcID() << "]\t";
90+
return rawstr.str();
8891
}
8992

9093
inline const ICFGEdge *getICFGEdge() const
@@ -578,13 +581,16 @@ struct DOTGraphTraits<SVF::CFBasicBlockGraph *> : public DOTGraphTraits<SVF::SVF
578581
{
579582
CFBasicBlockEdge* edge = *(EI.getCurrent());
580583
assert(edge && "No edge found!!");
581-
if (SVFUtil::isa<CallCFGEdge>(edge->getICFGEdge()))
582-
return "style=solid,color=red";
583-
else if (SVFUtil::isa<RetCFGEdge>(edge->getICFGEdge()))
584-
return "style=solid,color=blue";
585-
else
584+
if (edge->getICFGEdge()) {
585+
if (SVFUtil::isa<CallCFGEdge>(edge->getICFGEdge())){
586+
return "style=solid,color=red";}
587+
else if (SVFUtil::isa<RetCFGEdge>(edge->getICFGEdge()))
588+
return "style=solid,color=blue";
589+
else
590+
return "style=solid";
591+
} else {
586592
return "style=solid";
587-
return "";
593+
}
588594
}
589595

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

596602
std::string str;
597603
std::stringstream rawstr(str);
598-
if (const CallCFGEdge* dirCall = SVFUtil::dyn_cast<CallCFGEdge>(edge->getICFGEdge()))
599-
rawstr << dirCall->getCallSite();
600-
else if (const RetCFGEdge* dirRet = SVFUtil::dyn_cast<RetCFGEdge>(edge->getICFGEdge()))
601-
rawstr << dirRet->getCallSite();
602-
604+
if (edge->getICFGEdge()) {
605+
if (const CallCFGEdge* dirCall = SVFUtil::dyn_cast<CallCFGEdge>(edge->getICFGEdge()))
606+
rawstr << dirCall->getCallSite();
607+
else if (const RetCFGEdge* dirRet = SVFUtil::dyn_cast<RetCFGEdge>(edge->getICFGEdge()))
608+
rawstr << dirRet->getCallSite();
609+
}
603610
return rawstr.str();
604611
}
605612
};

0 commit comments

Comments
 (0)