Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unsigned int for callCount and costs to avoid integer overflow #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions library/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

struct ProxyData
{
ProxyData(int _calledIndex, int _lnr, int _cost) :
ProxyData(int _calledIndex, int _lnr, unsigned int _cost) :
calledIndex(_calledIndex), lnr(_lnr), cost(_cost)
{}

Expand All @@ -63,8 +63,8 @@ struct CallData

int functionNr;
int line;
int callCount;
int summedCallCost;
unsigned int callCount;
unsigned int summedCallCost;
};

inline CallData& insertGetOrderedMap(int functionNr, int line, std::map<int, size_t>& keyMap, std::vector<CallData>& data)
Expand All @@ -81,7 +81,7 @@ inline CallData& insertGetOrderedMap(int functionNr, int line, std::map<int, siz

struct FunctionData
{
FunctionData(const std::string& _name, std::string& _filename, int _line, int _cost) :
FunctionData(const std::string& _name, std::string& _filename, int _line, unsigned int _cost) :
name(_name),
filename(_filename),
line(_line),
Expand All @@ -93,9 +93,9 @@ struct FunctionData
std::string name;
std::string filename;
int line;
int invocationCount;
int summedSelfCost;
int summedInclusiveCost;
unsigned int invocationCount;
unsigned int summedSelfCost;
unsigned int summedInclusiveCost;
std::vector<CallData> calledFromInformation;
std::vector<CallData> subCallInformation;

Expand Down Expand Up @@ -142,7 +142,7 @@ class Webgrind_Preprocessor
std::string line;
std::string buffer;
int lnr;
int cost;
unsigned int cost;
int funcIndex;

// Read information into memory
Expand Down