Skip to content

Commit

Permalink
Merge pull request #12 from zenden2k/master
Browse files Browse the repository at this point in the history
Fixed "wrap around" of unsigned int in CParser::error(); Fixed memory leak in CSelector* CParser::parseSelector();
  • Loading branch information
lazytiger committed May 18, 2015
2 parents 6391c99 + 7778b36 commit 60a6d45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 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
8 changes: 5 additions & 3 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,9 +959,8 @@ 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 60a6d45

Please sign in to comment.