Skip to content

Commit

Permalink
Fixed memory leak in CSelector* CParser::parseSelector(); Fixed "wrap…
Browse files Browse the repository at this point in the history
… around" of unsigned int in CParser::error()
  • Loading branch information
zenden2k committed May 16, 2015
1 parent 6391c99 commit 42f0caf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CDocument::CDocument()
mpOutput = NULL;
}

void CDocument::parse(std::string aInput)
void CDocument::parse(const std::string& aInput)
{
reset();
mpOutput = gumbo_parse(aInput.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CDocument: public CObject

CDocument();

void parse(std::string aInput);
void parse(const std::string& aInput);

virtual ~CDocument();

Expand Down
10 changes: 6 additions & 4 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ CSelector* CParser::parseSelector()
return ret;
}

CSelector* oldRet = ret;
CSelector* sel = parseSimpleSelectorSequence();
if (combinator == ' ')
{
Expand All @@ -107,6 +108,8 @@ CSelector* CParser::parseSelector()
{
throw error("impossible");
}
oldRet->release();
sel->release();
}

throw error("impossible");
Expand Down Expand Up @@ -956,10 +959,9 @@ std::string CParser::error(std::string message)
}

std::string ret = message + " at:";
for (unsigned int i = ds.size() - 1; i >= 0; i--)
{
ret.push_back(ds[i]);
}
for (std::string::reverse_iterator rit = ds.rbegin(); rit != ds.rend(); ++rit) {
ret.push_back(*rit);
}

return ret;
}
Expand Down

0 comments on commit 42f0caf

Please sign in to comment.