Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

feature/txtr-s3-memory-leak #53

Open
wants to merge 1 commit into
base: develop
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
30 changes: 19 additions & 11 deletions ePub3/xml/tree/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,12 @@ void Node::SetName(const string &name)
}
string Node::Content() const
{
const xmlChar* ch = xmlNodeGetContent(_xml);
xmlChar* ch = xmlNodeGetContent(_xml);
if (ch == nullptr)
return string::EmptyString;
return ch;
string result(ch);
xmlFree(ch);
return result;
}
void Node::SetContent(const string &content)
{
Expand Down Expand Up @@ -249,10 +251,12 @@ void Node::SetNamespace(const class Namespace *ns)
}
string Node::Language() const
{
const xmlChar * ch = xmlNodeGetLang(_xml);
xmlChar * ch = xmlNodeGetLang(_xml);
if ( ch == nullptr )
return string();
return ch;
return string::EmptyString;
string result(ch);
xmlFree(ch);
return result;
}
void Node::SetLanguage(const string &language)
{
Expand All @@ -268,10 +272,12 @@ void Node::SetPreserveSpace(bool preserve)
}
string Node::BaseURL() const
{
const xmlChar * ch = xmlNodeGetBase(_xml->doc, _xml);
xmlChar * ch = xmlNodeGetBase(_xml->doc, _xml);
if ( ch == nullptr )
return string();
return ch;
return string::EmptyString;
string result(ch);
xmlFree(ch);
return result;
}
void Node::SetBaseURL(const string &baseURL)
{
Expand Down Expand Up @@ -350,10 +356,12 @@ string Node::XMLString() const
}
string Node::StringValue() const
{
const xmlChar * content = xmlNodeGetContent(_xml);
xmlChar * content = xmlNodeGetContent(_xml);
if ( content == nullptr )
return string();
return content;
return string::EmptyString;
string result(content);
xmlFree(content);
return result;
}
int Node::IntValue() const
{
Expand Down