0
我正在將libxml2與libxslt用於C++程序的XML處理。對於轉換XML文檔與XSL,我使用下面的函數(刪除錯誤處理):C++,libxslt:釋放樣式表文檔後釋放樣式表導致崩潰
xmlDocPtr
transformXmlDocument(
const xmlDocPtr inputDocument,
const std::string& stylesheetString
) {
exsltRegisterAll();
// Read the stylesheet document.
xmlDocPtr stylesheetDocument = xmlReadMemory(
stylesheetString.c_str(),
stylesheetString.length(),
"stylesheet.xsd",
0, // No encoding set - get it from the file header.
0 // No further options.
);
// Parse the stylesheet
xsltStylesheetPtr stylesheet = xsltParseStylesheetDoc(stylesheetDocument);
// Transform the document
xmlDocPtr result = xsltApplyStylesheet(stylesheet, inputDocument, 0);
// Free used resources
xsltFreeStylesheet(stylesheet);
xsltCleanupGlobals();
// Here the program crashes
xmlFreeDoc(stylesheetDocument);
return result;
}
的問題是,該方案與訪問衝突崩潰(glibc的說道:免費():無效的指針:0x00000000026d8090 *)在第二行。
我無法在文檔中找到xsltFreeStylesheet也釋放底層文檔或任何提示,所以這裏有什麼問題?
沒有閱讀過,只能閱讀:http://xmlsoft.org/XSLT/html/libxslt-xsltInternals.html#xsltFreeStylesheet ...謝謝。 – Jost