X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Futils%2Fxml-utils%2Fextract_xml.cpp;fp=tests%2Futils%2Fxml-utils%2Fextract_xml.cpp;h=ad319d3c46c10c01cda3cebd62ba92ef8fbf9993;hb=051356a81761338485706e779d046d7fb8dbfe1d;hp=3995dde48a27d9d96485f148222b883f58f4ef10;hpb=9617033a3a3229daabe17e38fbab802ec2e6e223;p=lttng-tools.git diff --git a/tests/utils/xml-utils/extract_xml.cpp b/tests/utils/xml-utils/extract_xml.cpp index 3995dde48..ad319d3c4 100644 --- a/tests/utils/xml-utils/extract_xml.cpp +++ b/tests/utils/xml-utils/extract_xml.cpp @@ -24,6 +24,8 @@ * node;b; * node;c; */ +#include "common.hpp" + #include #include @@ -176,8 +178,15 @@ static int extract_xpath(const char *xml_path, const xmlChar *xpath) LTTNG_ASSERT(xml_path); LTTNG_ASSERT(xpath); + xml_parser_ctx_uptr parserCtx{ xmlNewParserCtxt() }; + + if (!parserCtx) { + fprintf(stderr, "ERR: could not allocate an XML parser context\n"); + return -1; + } + /* Parse the xml file */ - doc = xmlParseFile(xml_path); + doc = xmlCtxtReadFile(parserCtx.get(), xml_path, nullptr, XML_PARSE_NOBLANKS); if (!doc) { fprintf(stderr, "ERR parsing: xml file invalid \"%s\"\n", xml_path); return -1; @@ -253,7 +262,6 @@ int main(int argc, char **argv) /* Init libxml */ xmlInitParser(); - xmlKeepBlanksDefault(0); if (access(argv[optind], F_OK)) { fprintf(stderr, "ERR:%s\n", "Xml path not valid"); return -1;