Permalink
Browse files

fix leak of xmlSAXHandler

  • Loading branch information...
1 parent f4707b5 commit 76750802f02d14b1115cbe586bad29ab0c69cea8 @triccardi-systran triccardi-systran committed Jul 17, 2012
Showing with 4 additions and 5 deletions.
  1. +3 −4 src/xml_sax_parser.cc
  2. +1 −1 src/xml_sax_parser.h
@@ -23,7 +23,6 @@ namespace libxmljs {
XmlSaxParser::XmlSaxParser()
: context_(NULL)
- , sax_handler_(new xmlSAXHandler)
{
xmlSAXHandler tmp = {
0, // internalSubset;
@@ -60,7 +59,7 @@ XmlSaxParser::XmlSaxParser()
0 // SaxParserCallback::structured_error // serror
};
- *sax_handler_ = tmp;
+ sax_handler_ = tmp;
}
XmlSaxParser::~XmlSaxParser() {
@@ -163,7 +162,7 @@ XmlSaxParser::Push(const v8::Arguments& args) {
void
XmlSaxParser::initialize_push_parser() {
- context_ = xmlCreatePushParserCtxt(sax_handler_, NULL, NULL, 0, "");
+ context_ = xmlCreatePushParserCtxt(&sax_handler_, NULL, NULL, 0, "");
context_->replaceEntities = 1;
initializeContext();
}
@@ -197,7 +196,7 @@ XmlSaxParser::parse_string(const char* str,
context_ = xmlCreateMemoryParserCtxt(str, size);
initializeContext();
context_->replaceEntities = 1;
- context_->sax = sax_handler_;
+ context_->sax = &sax_handler_;
xmlParseDocument(context_);
context_->sax = NULL;
releaseContext();
@@ -101,7 +101,7 @@ class XmlSaxParser : public node::ObjectWrap {
xmlParserCtxt* context_;
- xmlSAXHandler* sax_handler_;
+ xmlSAXHandler sax_handler_;
};
} // namespace libxmljs

0 comments on commit 7675080

Please sign in to comment.