From 14932d1b860cc59d51054b8db0b9756cb74bc7dd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 7 Oct 2015 14:36:32 +0200 Subject: [PATCH] allow to load huge VST plugin states -fixes #6623 by default libxml has a XML_MAX_TEXT_LENGTH of 10M with base64 encoding that allows at most 2.5MB state. set XML_PARSE_HUGE to read large sessions --- libs/pbd/xml++.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index 4e566a7800..963531c5f5 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -82,26 +82,23 @@ XMLTree::read_internal(bool validate) _doc = 0; } - xmlParserCtxtPtr ctxt = NULL; /* the parser context */ + /* create a parser context */ + xmlParserCtxtPtr ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + return false; + } xmlKeepBlanksDefault(0); /* parse the file, activating the DTD validation option */ if (validate) { - /* create a parser context */ - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - return false; - } _doc = xmlCtxtReadFile(ctxt, _filename.c_str(), NULL, XML_PARSE_DTDVALID); } else { - _doc = xmlParseFile(_filename.c_str()); + _doc = xmlCtxtReadFile(ctxt, _filename.c_str(), NULL, XML_PARSE_HUGE); } /* check if parsing suceeded */ if (_doc == NULL) { - if (validate) { - xmlFreeParserCtxt(ctxt); - } + xmlFreeParserCtxt(ctxt); return false; } else { /* check if validation suceeded */ @@ -114,9 +111,7 @@ XMLTree::read_internal(bool validate) _root = readnode(xmlDocGetRootElement(_doc)); /* free up the parser context */ - if (validate) { - xmlFreeParserCtxt(ctxt); - } + xmlFreeParserCtxt(ctxt); return true; }