Re: [xml] Segfaults on FreeBSD when using XPath....



        doc = xmlParseFile(argv[1]);
        printf("mem used =%d\n", xmlMemUsed());
        /* xmlMemDisplay(stdout); */
        root = xmlDocGetRootElement(doc);
        printf("Document root element name is %s\n", root->name);
        /*
         * Try to find root element using xpath...
         */
        xmlXPathInit();
        ctx = xmlXPathNewContext(doc);
        path = xmlXPathEvalExpression((const xmlChar
*)"id(\"calvin\")", ctx);
        printf("Document root element name is %s\n",
                path->nodesetval->nodeTab[0]->name);

Running it in a debugger shows that path->nodesetval->nodeTab is NULL.

You should probably check all pointers for NULL before you attempt to de-
reference them.


-Dave






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