[xml] Re: xmldocdump crash?



Hi Andries,

please use the libxml mailing list for discussion about libxml, unless
things are private and/or confidential. I don't see anything of the sort in
your mail, so I'll take the freedom to copy this to the list.

Hi Igor,

The program below causes a crash in libxml2, in the code for XmlDocDump
(libxml2-2.6.2.win32). Do you have any idea what might be the problem?
Something not initialized properly on win32 perhaps? I use vs 2003 btw.

greetings,

Andries

#include <stdlib.h>
#include <stdio.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

int main( int argc, char *argv[] )
{
xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;

    if (argc != 2)
        return(1);
/*
     * this initialize the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
    LIBXML_TEST_VERSION

    /*parse the file and get the DOM */
    doc = xmlParseFile(argv[1]);

    if (doc == NULL) {
        printf("error: could not parse file file.xml\n");
    }

    /*Get the root element node */
    root_element = xmlDocGetRootElement(doc);

// xmlSaveFile( "d:\\temp\\test2.xml", doc );
xmlDocDump( stdout, doc );

    /*free the document */
    xmlFreeDoc(doc);

    /*
     *Free the global variables that may
     *have been allocated by the parser.
     */
    xmlCleanupParser();

    return 0;
}

The only thing I can think of is that you perhaps linked your app to the
runtime which is different to the one used by libxml. Try setting your
runtime to 'multithreaded dll' and see if things get any better.

By the way, if this really is the root of the problem, it is a perfect
example for the incompatibility of stdout between runtimes, a thing I posted
about five minutes ago. :-)

Ciao,
Igor




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]