From 0ac7e2a2da80fb2294753da3c3e7b06e44b9897a Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Wed, 3 Apr 2013 21:27:02 +0200 Subject: [PATCH] Fix bug in libxml patch See http://tickets.musicbrainz.org/browse/LMB-34?focusedCommentId=27184 and http://lists.musicbrainz.org/pipermail/musicbrainz-devel/2013-March/005191.html The xmlError structure were not initialized before being used, causing use of unitialized memory, and then failure of the test case (use of -D_FORTIFY_SOURCE=2 seemed to make a difference on the test case behaviour) --- 0001-xmlparsing.patch | 428 +++++++++++++++++++++--------------------- 1 file changed, 216 insertions(+), 212 deletions(-) diff --git a/0001-xmlparsing.patch b/0001-xmlparsing.patch index 465f767..0cadff4 100644 --- a/0001-xmlparsing.patch +++ b/0001-xmlparsing.patch @@ -1,7 +1,8 @@ -diff -up libmusicbrainz-5.0.1/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/CMakeLists.txt ---- libmusicbrainz-5.0.1/CMakeLists.txt.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/CMakeLists.txt 2013-01-07 12:51:33.916020435 -0500 -@@ -20,6 +20,7 @@ SET(musicbrainz5_SOVERSION ${musicbrainz +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 16870b4..a1f5a65 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,6 +20,7 @@ SET(musicbrainz5_SOVERSION ${musicbrainz5_SOVERSION_MAJOR}) SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) FIND_PACKAGE(Neon REQUIRED) @@ -9,9 +10,10 @@ diff -up libmusicbrainz-5.0.1/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/CMak SET(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") SET(EXEC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Installation prefix for executables and object code libraries" FORCE) -diff -up libmusicbrainz-5.0.1/examples/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/examples/CMakeLists.txt ---- libmusicbrainz-5.0.1/examples/CMakeLists.txt.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/examples/CMakeLists.txt 2013-01-07 12:51:33.917020435 -0500 +diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt +index 3e11469..440d4f2 100644 +--- a/examples/CMakeLists.txt ++++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) -LINK_LIBRARIES(musicbrainz5 ${NEON_LIBRARIES}) @@ -20,9 +22,10 @@ diff -up libmusicbrainz-5.0.1/examples/CMakeLists.txt.xmlParser libmusicbrainz-5 ADD_EXECUTABLE(cdlookup cdlookup.cc) ADD_EXECUTABLE(cdlookup_c cdlookup_c.c) -diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h ---- libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h 2013-01-07 12:51:33.918020435 -0500 +diff --git a/include/musicbrainz5/xmlParser.h b/include/musicbrainz5/xmlParser.h +index 56b29d7..45db5fc 100644 +--- a/include/musicbrainz5/xmlParser.h ++++ b/include/musicbrainz5/xmlParser.h @@ -1,733 +1,111 @@ -/****************************************************************************/ -/*! \mainpage XMLParser library @@ -108,12 +111,15 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * work.has been done. - * - ****************************************************************************/ -- ++/* -------------------------------------------------------------------------- + -#ifndef __INCLUDE_XML_NODE__ -#define __INCLUDE_XML_NODE__ -- ++ libmusicbrainz5 - Client library to access MusicBrainz + -#include -- ++ Copyright (C) 2012 Christophe Fergeau + -#ifdef _UNICODE -// If you comment the next "define" line then the library will never "switch to" _UNICODE (wchar_t*) mode (16/32 bits per characters). -// This is useful when you get error messages like: @@ -122,14 +128,12 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi -// must be defined) or utf8-mode(the pre-processor variable must be undefined). -#define _XMLWIDECHAR -#endif -+/* -------------------------------------------------------------------------- - +- -#if defined(WIN32) || defined(UNDER_CE) || defined(_WIN32) || defined(WIN64) || defined(__BORLANDC__) -// comment the next line if you are under windows and the compiler is not Microsoft Visual Studio (6.0 or .NET) or Borland -#define _XMLWINDOWS -#endif -+ libmusicbrainz5 - Client library to access MusicBrainz - +- -#ifdef XMLDLLENTRY -#undef XMLDLLENTRY -#endif @@ -142,19 +146,22 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi -#else -#define XMLDLLENTRY -#endif -+ Copyright (C) 2012 Christophe Fergeau ++ This file is part of libmusicbrainz5. -// uncomment the next line if you want no support for wchar_t* (no need for the or libraries anymore to compile) -//#define XML_NO_WIDE_CHAR -+ This file is part of libmusicbrainz5. ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of v2 of the GNU Lesser General Public ++ License as published by the Free Software Foundation. -#ifdef XML_NO_WIDE_CHAR -#undef _XMLWINDOWS -#undef _XMLWIDECHAR -#endif -+ This library is free software; you can redistribute it and/or -+ modify it under the terms of v2 of the GNU Lesser General Public -+ License as published by the Free Software Foundation. ++ libmusicbrainz5 is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. -#ifdef _XMLWINDOWS -#include @@ -165,10 +172,8 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - // to have 'mbsrtowcs' for WIDECHAR version -#endif -#endif -+ libmusicbrainz5 is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. ++ You should have received a copy of the GNU General Public License ++ along with this library. If not, see . -// Some common types for char set portable code -#ifdef _XMLWIDECHAR @@ -188,27 +193,15 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi -#ifndef TRUE - #define TRUE 1 -#endif /* TRUE */ -+ You should have received a copy of the GNU General Public License -+ along with this library. If not, see . -+ + $Id$ -+ + +----------------------------------------------------------------------------*/ +#ifndef _MUSICBRAINZ5_XMLPARSER_H +#define _MUSICBRAINZ5_XMLPARSER_H -+ -+#include -+#include -+ -+typedef xmlError XMLResults; - -+const int eXMLErrorNone = 0; -/// Enumeration for XML parse errors. -typedef enum XMLError -+class XMLAttribute; -+class XMLNode - { +-{ - eXMLErrorNone = 0, - eXMLErrorMissingEndTag, - eXMLErrorNoXMLTagFound, @@ -232,47 +225,26 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - eXMLErrorBase64DecodeTruncatedData, - eXMLErrorBase64DecodeBufferTooSmall -} XMLError; -+ public: -+ static XMLNode emptyNode(); -+ bool isEmpty() const; ++#include ++#include -+ virtual ~XMLNode() {}; ++typedef xmlError XMLResults; -/// Enumeration used to manage type of data. Use in conjunction with structure XMLNodeContents -typedef enum XMLElementType -+ const XMLAttribute getAttribute(const char *name = NULL) const; -+ bool isAttributeSet(const char *name) const; -+ -+ XMLNode getChildNode(const char *name = NULL) const; -+ XMLNode next() const; -+ const char *getName() const; -+ const char *getText() const; -+ -+ friend bool operator== (const XMLNode &lhs, const XMLNode &rhs); -+ -+ protected: -+ XMLNode(xmlNodePtr node): mNode(node) {}; -+ -+ xmlNodePtr mNode; -+ -+ private: -+ xmlAttrPtr getAttributeRaw(const char *name) const; -+}; -+ -+inline bool operator== (const XMLNode &lhs, const XMLNode &rhs) - { +-{ - eNodeChild=0, - eNodeAttribute=1, - eNodeText=2, - eNodeClear=3, - eNodeNULL=4 -} XMLElementType; -+ return (lhs.mNode == rhs.mNode); -+} ++const int eXMLErrorNone = 0; -/// Structure used to obtain error details if the parse fails. -typedef struct XMLResults -+inline bool operator!= (const XMLNode &lhs, const XMLNode &rhs) ++class XMLAttribute; ++class XMLNode { - enum XMLError error; - int nLine,nColumn; @@ -306,19 +278,11 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - *
  • XMLNode::createXMLTopNode (or XMLNode::createXMLTopNode_WOSD)
  • - * */ -typedef struct XMLDLLENTRY XMLNode -+ return !(lhs == rhs); -+} -+ -+class XMLRootNode: public XMLNode - { +-{ - private: -+ public: -+ static XMLNode* parseString(std::string &xml, XMLResults *results); -+ static XMLNode* parseFile(const std::string &filename, XMLResults *results); - +- - struct XMLNodeDataTag; -+ virtual ~XMLRootNode() { if (mDoc != NULL) xmlFreeDoc(mDoc); }; - +- - /// Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode - XMLNode(struct XMLNodeDataTag *pParent, XMLSTR lpszName, char isDeclaration); - /// Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode @@ -356,7 +320,10 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * @param tag the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (). - * @param pResults a pointer to a XMLResults variable that will contain some information that can be used to trace the XML parsing error. You can have a user-friendly explanation of the parsing error with the "getError" function. - */ -- ++ public: ++ static XMLNode emptyNode(); ++ bool isEmpty() const; + - /// Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made. - static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag=NULL); - /**< The "openFileHelper" function reports to the screen all the warnings and errors that occurred during parsing of the XML file. @@ -375,16 +342,23 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * @param filename the path of the XML file to parse. - * @param tag the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (). - */ -- ++ virtual ~XMLNode() {}; + - static XMLCSTR getError(XMLError error); ///< this gives you a user-friendly explanation of the parsing error -- ++ const XMLAttribute getAttribute(const char *name = NULL) const; ++ bool isAttributeSet(const char *name) const; + - /// Create an XML string starting from the current XMLNode. - XMLSTR createXMLString(int nFormat=1, int *pnSize=NULL) const; - /**< The returned string should be free'd using the "freeXMLString" function. - * - * If nFormat==0, no formatting is required otherwise this returns an user friendly XML string from a given element - * with appropriate white spaces and carriage returns. if pnSize is given it returns the size in character of the string. */ -- ++ XMLNode getChildNode(const char *name = NULL) const; ++ XMLNode next() const; ++ const char *getName() const; ++ const char *getText() const; + - /// Save the content of an xmlNode inside a file - XMLError writeToFile(XMLCSTR filename, - const char *encoding=NULL, @@ -395,7 +369,8 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * If "_XMLWIDECHAR=1", then the "encoding" parameter is ignored and always set to "utf-16". - * If no "encoding" parameter is given the "ISO-8859-1" encoding is used. */ - /** @} */ -- ++ friend bool operator== (const XMLNode &lhs, const XMLNode &rhs); + - /** @defgroup navigate Navigate the XMLNode structure - * @ingroup XMLParserGeneral - * @{ */ @@ -414,7 +389,9 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - ///< return the first child node with specific path - XMLNode getChildNodeByPathNonConst(XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/'); - ///< return the first child node with specific path. -- ++ protected: ++ XMLNode(xmlNodePtr node): mNode(node) {}; + - int nChildNode(XMLCSTR name) const; ///< return the number of child node with specific name - int nChildNode() const; ///< nbr of child node - XMLAttribute getAttribute(int i=0) const; ///< return ith attribute @@ -433,11 +410,15 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - XMLNode deepCopy() const; ///< deep copy (duplicate/clone) a XMLNode - static XMLNode emptyNode(); ///< return XMLNode::emptyXMLNode; - /** @} */ -- ++ xmlNodePtr mNode; + - ~XMLNode(); - XMLNode(const XMLNode &A); ///< to allow shallow/fast copy: - XMLNode& operator=( const XMLNode& A ); ///< to allow shallow/fast copy: -- ++ private: ++ xmlAttrPtr getAttributeRaw(const char *name) const; ++}; + - XMLNode(): d(NULL){}; - static XMLNode emptyXMLNode; - static XMLClear emptyXMLClear; @@ -684,12 +665,11 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - static void exactMemory(XMLNodeData *d); - static int detachFromParent(XMLNodeData *d); -} XMLNode; -+ private: -+ XMLRootNode(xmlDocPtr doc); - +- -/// This structure is given by the function XMLNode::enumContents. -typedef struct XMLNodeContents --{ ++inline bool operator== (const XMLNode &lhs, const XMLNode &rhs) + { - /// This dictates what's the content of the XMLNodeContent - enum XMLElementType etype; - /**< should be an union to access the appropriate data. Compiler does not allow union of object with constructor... too bad. */ @@ -709,7 +689,9 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * a very handy function when used with all the "XMLNode::*_WOSD" functions (\link xmlWOSD \endlink). - * @param cbData If !=0 then cbData is the number of chars to duplicate. New strings allocated with - * this function should be free'd using the "freeXMLString" function. */ -- ++ return (lhs.mNode == rhs.mNode); ++} + -/// to free the string allocated inside the "stringDup" function or the "createXMLString" function. -XMLDLLENTRY void freeXMLString(XMLSTR t); // {free(t);} -/** @} */ @@ -745,14 +727,17 @@ diff -up libmusicbrainz-5.0.1/include/musicbrainz5/xmlParser.h.xmlParser libmusi - * you must not use the "ToXMLStringTool" class (because the "XMLNode" class does the - * processing job for you during rendering).*/ -typedef struct XMLDLLENTRY ToXMLStringTool --{ ++inline bool operator!= (const XMLNode &lhs, const XMLNode &rhs) + { -public: - ToXMLStringTool(): buf(NULL),buflen(0){} - ~ToXMLStringTool(); - void freeBuffer();///= 0.25 @@ -857,35 +851,10 @@ diff -up libmusicbrainz-5.0.1/libmusicbrainz5.pc.cmake.xmlParser libmusicbrainz- Libs: -L${LIB_INSTALL_DIR} -lmusicbrainz5 Cflags: -I${INCLUDE_INSTALL_DIR} -diff -up libmusicbrainz-5.0.1/src/cinterface.xml.xmlParser libmusicbrainz-5.0.1/src/cinterface.xml ---- libmusicbrainz-5.0.1/src/cinterface.xml.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/src/cinterface.xml 2013-01-07 12:52:21.992035823 -0500 -@@ -1,5 +1,4 @@ - - - -@@ -218,7 +216,7 @@ extern "C" - - - -- -+ - - - -diff -up libmusicbrainz-5.0.1/src/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/src/CMakeLists.txt ---- libmusicbrainz-5.0.1/src/CMakeLists.txt.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/src/CMakeLists.txt 2013-01-07 12:51:33.919020436 -0500 +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 2ee102f..368dd93 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt @@ -1,14 +1,15 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../include ${NEON_INCLUDE_DIR}) @@ -923,10 +892,11 @@ diff -up libmusicbrainz-5.0.1/src/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/ ENDIF(CMAKE_COMPILER_IS_GNUCXX) INSTALL(TARGETS musicbrainz5 DESTINATION ${LIB_INSTALL_DIR}) -diff -up libmusicbrainz-5.0.1/src/Entity.cc.xmlParser libmusicbrainz-5.0.1/src/Entity.cc ---- libmusicbrainz-5.0.1/src/Entity.cc.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/src/Entity.cc 2013-01-07 12:51:33.919020436 -0500 -@@ -80,10 +80,12 @@ void MusicBrainz5::CEntity::Parse(const +diff --git a/src/Entity.cc b/src/Entity.cc +index 0644377..a1bb1ca 100644 +--- a/src/Entity.cc ++++ b/src/Entity.cc +@@ -80,10 +80,12 @@ void MusicBrainz5::CEntity::Parse(const XMLNode& Node) { if (!Node.isEmpty()) { @@ -942,7 +912,7 @@ diff -up libmusicbrainz-5.0.1/src/Entity.cc.xmlParser libmusicbrainz-5.0.1/src/E if ("ext:"==Name.substr(0,4)) m_d->m_ExtAttributes[Name.substr(4)]=Value; -@@ -93,10 +95,10 @@ void MusicBrainz5::CEntity::Parse(const +@@ -93,10 +95,10 @@ void MusicBrainz5::CEntity::Parse(const XMLNode& Node) //std::cout << "Node: " << std::endl << Node.createXMLString(true) << std::endl; @@ -956,29 +926,107 @@ diff -up libmusicbrainz-5.0.1/src/Entity.cc.xmlParser libmusicbrainz-5.0.1/src/E std::string Name=ChildNode.getName(); std::string Value; if (ChildNode.getText()) -diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5.0.1/src/make-c-interface.cc ---- libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/src/make-c-interface.cc 2013-01-07 12:51:33.920020438 -0500 -@@ -28,6 +28,7 @@ +diff --git a/src/Query.cc b/src/Query.cc +index d132ae7..a835c84 100644 +--- a/src/Query.cc ++++ b/src/Query.cc +@@ -158,15 +158,17 @@ MusicBrainz5::CMetadata MusicBrainz5::CQuery::PerformQuery(const std::string& Qu + #endif + + XMLResults Results; +- XMLNode TopNode=XMLNode::parseString(strData.c_str(), 0, &Results); +- if (Results.error==eXMLErrorNone) ++ memset(&Results, 0, sizeof(Results)); ++ XMLNode *TopNode = XMLRootNode::parseString(strData, &Results); ++ if (Results.code==eXMLErrorNone) + { +- XMLNode MetadataNode=TopNode.getChildNode("metadata"); ++ XMLNode MetadataNode=*TopNode; + if (!MetadataNode.isEmpty()) + { + Metadata=CMetadata(MetadataNode); + } + } ++ delete TopNode; + } + } + +@@ -393,10 +395,11 @@ bool MusicBrainz5::CQuery::EditCollection(const std::string& CollectionID, const + #endif + + XMLResults Results; +- XMLNode TopNode=XMLNode::parseString(strData.c_str(), 0, &Results); +- if (Results.error==eXMLErrorNone) ++ memset(&Results, 0, sizeof(Results)); ++ XMLNode *TopNode = XMLRootNode::parseString(strData, &Results); ++ if (Results.code==eXMLErrorNone) + { +- XMLNode MetadataNode=TopNode.getChildNode("metadata"); ++ XMLNode MetadataNode=*TopNode; + if (!MetadataNode.isEmpty()) + { + CMetadata Metadata(MetadataNode); +@@ -405,6 +408,7 @@ bool MusicBrainz5::CQuery::EditCollection(const std::string& CollectionID, const + RetVal=RetVal && true; + } + } ++ delete TopNode; + } + } + +diff --git a/src/cinterface.xml b/src/cinterface.xml +index ae5cf92..f492fd1 100644 +--- a/src/cinterface.xml ++++ b/src/cinterface.xml +@@ -1,5 +1,4 @@ + + + +@@ -218,7 +216,7 @@ extern "C" + + + +- ++ + + + +diff --git a/src/make-c-interface.cc b/src/make-c-interface.cc +index 652a65b..97af3d9 100644 +--- a/src/make-c-interface.cc ++++ b/src/make-c-interface.cc +@@ -28,6 +28,8 @@ #include #include #include ++#include +#include #include #include -@@ -51,8 +52,8 @@ int main(int argc, const char *argv[]) +@@ -51,8 +53,9 @@ int main(int argc, const char *argv[]) { std::string XMLFile=std::string(argv[1])+"/"+argv[2]; XMLResults Results; - XMLNode TopNode=XMLNode::parseFile(XMLFile.c_str(),"cinterface",&Results); - if (!TopNode.isEmpty()) + XMLNode *TopNode=XMLRootNode::parseFile(XMLFile.c_str(),&Results); ++ memset(&Results, 0, sizeof(Results)); + if (!TopNode->isEmpty()) { std::cout << "Generating '" << argv[3] << "/" << argv[4] << "' and '" << argv[3] << "/" << argv[5] << "'" << std::endl; -@@ -74,9 +75,10 @@ int main(int argc, const char *argv[]) +@@ -74,9 +77,10 @@ int main(int argc, const char *argv[]) return 1; } @@ -991,7 +1039,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 std::string Name=Node.getName(); if ("boilerplate"==Name) -@@ -84,7 +86,7 @@ int main(int argc, const char *argv[]) +@@ -84,7 +88,7 @@ int main(int argc, const char *argv[]) else if ("header"==Name) ProcessHeader(Node,Source,Include); else if ("declare"==Name) @@ -1000,7 +1048,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 else if ("entity"==Name) ProcessEntity(Node,Source,Include); else if ("class"==Name) -@@ -100,9 +102,11 @@ int main(int argc, const char *argv[]) +@@ -100,9 +104,11 @@ int main(int argc, const char *argv[]) } else { @@ -1013,7 +1061,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 } return 0; -@@ -114,7 +118,7 @@ std::ofstream *GetFile(const XMLNode& No +@@ -114,7 +120,7 @@ std::ofstream *GetFile(const XMLNode& Node, std::ofstream& Source, std::ofstream if (Node.isAttributeSet("target")) { @@ -1022,7 +1070,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 if ("source"==Target) File=&Source; else if ("include"==Target) -@@ -162,7 +166,7 @@ void ProcessBoilerplate(const XMLNode& N +@@ -162,7 +168,7 @@ void ProcessBoilerplate(const XMLNode& Node, std::ofstream& Source, std::ofstrea if (Node.isAttributeSet("file")) { @@ -1031,7 +1079,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 std::ifstream InFile(FileName.c_str()); if (InFile.is_open()) *File << InFile.rdbuf() << std::endl; -@@ -263,11 +267,11 @@ void ProcessClass(const XMLNode& Node, s +@@ -263,11 +269,11 @@ void ProcessClass(const XMLNode& Node, std::ofstream& Source, std::ofstream& Inc { if (Node.isAttributeSet("name")) { @@ -1045,7 +1093,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 else UpperName[0]=toupper(UpperName[0]); -@@ -294,24 +298,25 @@ void ProcessClass(const XMLNode& Node, s +@@ -294,24 +300,25 @@ void ProcessClass(const XMLNode& Node, std::ofstream& Source, std::ofstream& Inc Source << " MB5_C_CLONE(" << UpperName << "," << LowerName << ")" << std::endl; @@ -1076,7 +1124,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 if ("string"==PropertyType) { -@@ -320,13 +325,13 @@ void ProcessClass(const XMLNode& Node, s +@@ -320,13 +327,13 @@ void ProcessClass(const XMLNode& Node, std::ofstream& Source, std::ofstream& Inc if (ChildNode.isAttributeSet("deprecated")) { @@ -1092,7 +1140,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 } Include << "/**" << std::endl; -@@ -470,11 +475,11 @@ void ProcessList(const XMLNode& Node, st +@@ -470,11 +477,11 @@ void ProcessList(const XMLNode& Node, std::ofstream& Source, std::ofstream& Incl { if (Node.isAttributeSet("name")) { @@ -1106,7 +1154,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 else UpperName[0]=toupper(UpperName[0]); -@@ -532,24 +537,25 @@ void ProcessList(const XMLNode& Node, st +@@ -532,24 +539,25 @@ void ProcessList(const XMLNode& Node, std::ofstream& Source, std::ofstream& Incl Source << " MB5_C_CLONE(" << UpperName << "List," << LowerName << "_list)" << std::endl; @@ -1137,7 +1185,7 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 if ("string"==PropertyType) { -@@ -637,18 +643,19 @@ void ProcessDeclare(const XMLNode& Node, +@@ -637,18 +645,19 @@ void ProcessDeclare(const XMLNode& Node, std::ofstream& /*Source*/, std::ofstrea std::vector Classes; Classes.push_back("Entity"); @@ -1161,55 +1209,12 @@ diff -up libmusicbrainz-5.0.1/src/make-c-interface.cc.xmlParser libmusicbrainz-5 else UpperName[0]=toupper(UpperName[0]); -diff -up libmusicbrainz-5.0.1/src/Query.cc.xmlParser libmusicbrainz-5.0.1/src/Query.cc ---- libmusicbrainz-5.0.1/src/Query.cc.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/src/Query.cc 2013-01-07 12:51:33.921020440 -0500 -@@ -158,15 +158,16 @@ MusicBrainz5::CMetadata MusicBrainz5::CQ - #endif - - XMLResults Results; -- XMLNode TopNode=XMLNode::parseString(strData.c_str(), 0, &Results); -- if (Results.error==eXMLErrorNone) -+ XMLNode *TopNode = XMLRootNode::parseString(strData, &Results); -+ if (Results.code==eXMLErrorNone) - { -- XMLNode MetadataNode=TopNode.getChildNode("metadata"); -+ XMLNode MetadataNode=*TopNode; - if (!MetadataNode.isEmpty()) - { - Metadata=CMetadata(MetadataNode); - } - } -+ delete TopNode; - } - } - -@@ -393,10 +394,10 @@ bool MusicBrainz5::CQuery::EditCollectio - #endif - - XMLResults Results; -- XMLNode TopNode=XMLNode::parseString(strData.c_str(), 0, &Results); -- if (Results.error==eXMLErrorNone) -+ XMLNode *TopNode = XMLRootNode::parseString(strData, &Results); -+ if (Results.code==eXMLErrorNone) - { -- XMLNode MetadataNode=TopNode.getChildNode("metadata"); -+ XMLNode MetadataNode=*TopNode; - if (!MetadataNode.isEmpty()) - { - CMetadata Metadata(MetadataNode); -@@ -405,6 +406,7 @@ bool MusicBrainz5::CQuery::EditCollectio - RetVal=RetVal && true; - } - } -+ delete TopNode; - } - } - -diff -up libmusicbrainz-5.0.1/src/xmlParser.cc.xmlParser libmusicbrainz-5.0.1/src/xmlParser.cc ---- libmusicbrainz-5.0.1/src/xmlParser.cc.xmlParser 2013-01-07 12:51:33.921020440 -0500 -+++ libmusicbrainz-5.0.1/src/xmlParser.cc 2013-01-07 12:51:33.921020440 -0500 -@@ -0,0 +1,147 @@ +diff --git a/src/xmlParser.cc b/src/xmlParser.cc +new file mode 100644 +index 0000000..41af44b +--- /dev/null ++++ b/src/xmlParser.cc +@@ -0,0 +1,145 @@ +/* -------------------------------------------------------------------------- + + libmusicbrainz5 - Client library to access MusicBrainz @@ -1355,11 +1360,10 @@ diff -up libmusicbrainz-5.0.1/src/xmlParser.cc.xmlParser libmusicbrainz-5.0.1/sr +{ + return mNode == NULL; +} -+ -+ -diff -up libmusicbrainz-5.0.1/tests/CMakeLists.txt.xmlParser libmusicbrainz-5.0.1/tests/CMakeLists.txt ---- libmusicbrainz-5.0.1/tests/CMakeLists.txt.xmlParser 2012-05-16 15:48:34.000000000 -0400 -+++ libmusicbrainz-5.0.1/tests/CMakeLists.txt 2013-01-07 12:51:33.922020441 -0500 +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 645f8ae..8dd569c 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) -LINK_LIBRARIES(musicbrainz5 ${NEON_LIBRARIES})