Static Value-Flow Analysis
Public Member Functions | Static Public Member Functions | List of all members
SVF::PartialLeakBug Class Reference

#include <SVFBugReport.h>

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

Public Member Functions

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

Static Public Member Functions

static bool classof (const GenericBug *bug)
 ClassOf. More...
 

Additional Inherited Members

- Public Types inherited from SVF::GenericBug
enum  BugType {
  FULLBUFOVERFLOW , PARTIALBUFOVERFLOW , NEVERFREE , PARTIALLEAK ,
  DOUBLEFREE , FILENEVERCLOSE , FILEPARTIALCLOSE , FULLNULLPTRDEREFERENCE ,
  PARTIALNULLPTRDEREFERENCE
}
 
typedef std::vector< SVFBugEventEventStack
 
- Static Public Attributes inherited from SVF::GenericBug
static const std::map< GenericBug::BugType, std::stringBugType2Str
 
- Protected Attributes inherited from SVF::GenericBug
BugType bugType
 
const EventStack bugEventStack
 

Detailed Description

Definition at line 192 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ PartialLeakBug()

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

Definition at line 195 of file SVFBugReport.h.

195  :
GenericBug(BugType bugType, const EventStack &bugEventStack)
note: should be initialized with a bugEventStack
Definition: SVFBugReport.h:95
const EventStack bugEventStack
Definition: SVFBugReport.h:91

Member Function Documentation

◆ classof()

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

ClassOf.

Definition at line 202 of file SVFBugReport.h.

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

◆ getBugDescription()

cJSON * PartialLeakBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 128 of file SVFBugReport.cpp.

129 {
130  cJSON *bugDescription = cJSON_CreateObject();
131  cJSON *pathInfo = cJSON_CreateArray();
132  auto lastBranchEventIt = bugEventStack.end() - 1;
133  for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
134  {
135  cJSON *newBranch = cJSON_CreateObject();
136  cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
137  if(branchLoc == nullptr) branchLoc = cJSON_CreateObject();
138 
139  cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
140 
141  cJSON_AddItemToObject(newBranch, "BranchLoc", branchLoc);
142  cJSON_AddItemToObject(newBranch, "BranchCond", branchCondition);
143 
144  cJSON_AddItemToArray(pathInfo, newBranch);
145  }
146 
147  cJSON_AddItemToObject(bugDescription, "ConditionalFreePath", pathInfo);
148 
149  return bugDescription;
150 }
Definition: cJSON.h:104

◆ printBugToTerminal()

void PartialLeakBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 152 of file SVFBugReport.cpp.

153 {
154  SVFUtil::errs() << SVFUtil::bugMsg2("\t PartialLeak :") << " memory allocation at : ("
155  << GenericBug::getLoc() << ")\n";
156 
157  SVFUtil::errs() << "\t\t conditional free path: \n";
158  auto lastBranchEventIt = bugEventStack.end() - 1;
159  for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
160  {
161  SVFUtil::errs() << "\t\t --> (" << (*eventIt).getEventLoc() << "|" << (*eventIt).getEventDescription() << ") \n";
162  }
163  SVFUtil::errs() << "\n";
164 }
const std::string getLoc() const
returns bug location as json format string
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56
std::string bugMsg2(const std::string &msg)
Definition: SVFUtil.cpp:86

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