C++, libxslt: Freeing the stylesheet document after freeing the style sheet results in crash

I'm using libxml2 with libxslt for XML processing from a C++ program. For transforming XML documents with XSL, I use the following function (error handling removed):

    const xmlDocPtr inputDocument,
    const std::string& stylesheetString
    ) {


    // Read the stylesheet document.
    xmlDocPtr stylesheetDocument = xmlReadMemory(
            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

    // Here the program crashes

    return result;

The problem is that the program crashes with an access violation (glibc says: free(): invalid pointer: 0x00000000026d8090 *) in the second last line.

I can't find any hints in the docs that xsltFreeStylesheet also frees the underlying document or something, so what is wrong here?


xsltFreeStylesheet also frees the underlying document or something

The fine manual has some hints which would suggest that there's indeed a chance of this scenario happening.

Need Your Help

NoSuchBeanDefinitionException when add @PreAuthorize annotation

spring gwt spring-security requestfactory

I'm trying to perform integration of my GWT application and Spring Security. And when I add @PreAuthorize("hasRole('ROLE_USER')") annotation to the method of my DAO class following exception appear...

Iphone variable is loading syntax it seems and not the variable

iphone objective-c ios variables

I'm assigning a variable string from an XML node and for some reason when i'm using it later i'm getting it read like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.