Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::PartialLeakBug Class Reference

#include <SVFBugReport.h>

Inheritance diagram for SVF::PartialLeakBug:
SVF::GenericBug

Public Member Functions

 PartialLeakBug (const EventStack &bugEventStack)
cJSON * getBugDescription () const
void printBugToTerminal () const
Public Member Functions inherited from SVF::GenericBug
 GenericBug (BugType bugType, const EventStack &bugEventStack)
 note: should be initialized with a bugEventStack
virtual ~GenericBug ()=default
BugType getBugType () const
 returns bug type
const std::string getLoc () const
 returns bug location as json format string
const std::string getFuncName () const
 return bug source function name
const EventStack & getEventStack () const

Static Public Member Functions

static bool classof (const GenericBug *bug)
 ClassOf.

Additional Inherited Members

Public Types inherited from SVF::GenericBug
enum  BugType {
  FULLBUFOVERFLOW , PARTIALBUFOVERFLOW , NEVERFREE , PARTIALLEAK ,
  DOUBLEFREE , FILENEVERCLOSE , FILEPARTIALCLOSE , FULLNULLPTRDEREFERENCE ,
  PARTIALNULLPTRDEREFERENCE
}
typedef std::vector< SVFBugEvent > EventStack
Static Public Attributes inherited from SVF::GenericBug
static const OrderedMap< GenericBug::BugType, std::string > BugType2Str
Protected Attributes inherited from SVF::GenericBug
BugType bugType
const EventStack bugEventStack

Detailed Description

Definition at line 191 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ PartialLeakBug()

SVF::PartialLeakBug::PartialLeakBug ( const EventStack & bugEventStack)
inline

Definition at line 194 of file SVFBugReport.h.

194 :
GenericBug(BugType bugType, const EventStack &bugEventStack)
note: should be initialized with a bugEventStack
const EventStack bugEventStack

Member Function Documentation

◆ classof()

bool SVF::PartialLeakBug::classof ( const GenericBug * bug)
inlinestatic

ClassOf.

Definition at line 201 of file SVFBugReport.h.

202 {
203 return bug->getBugType() == GenericBug::PARTIALLEAK;
204 }

◆ getBugDescription()

cJSON * PartialLeakBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 143 of file SVFBugReport.cpp.

144{
145 cJSON *bugDescription = cJSON_CreateObject();
146 cJSON *pathInfo = cJSON_CreateArray();
147 auto lastBranchEventIt = bugEventStack.end() - 1;
148 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
149 {
150 cJSON *newBranch = cJSON_CreateObject();
151 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
152 if(branchLoc == nullptr) branchLoc = cJSON_CreateObject();
153
154 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
155
156 cJSON_AddItemToObject(newBranch, "BranchLoc", branchLoc);
157 cJSON_AddItemToObject(newBranch, "BranchCond", branchCondition);
158
159 cJSON_AddItemToArray(pathInfo, newBranch);
160 }
161
162 cJSON_AddItemToObject(bugDescription, "ConditionalFreePath", pathInfo);
163
164 return bugDescription;
165}
struct cJSON cJSON

◆ printBugToTerminal()

void PartialLeakBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 167 of file SVFBugReport.cpp.

168{
169 SVFUtil::errs() << SVFUtil::bugMsg2("\t PartialLeak :") << " memory allocation at : ("
170 << GenericBug::getLoc() << ")\n";
171
172 SVFUtil::errs() << "\t\t conditional free path: \n";
173 auto lastBranchEventIt = bugEventStack.end() - 1;
174 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
175 {
176 SVFUtil::errs() << "\t\t --> (" << (*eventIt).getEventLoc() << "|" << (*eventIt).getEventDescription() << ") \n";
177 }
178 SVFUtil::errs() << "\n";
179}
const std::string getLoc() const
returns bug location as json format string
std::ostream & errs()
Overwrite llvm::errs().
Definition SVFUtil.h:64
std::string bugMsg2(const std::string &msg)
Definition SVFUtil.cpp:108

The documentation for this class was generated from the following files: