Re: BUG #3860: xpath crashes backend when is querying xmlagg result - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #3860: xpath crashes backend when is querying xmlagg result
Date
Msg-id 20080111034140.GV6465@alvh.no-ip.org
Whole thread Raw
In response to Re: BUG #3860: xpath crashes backend when is querying xmlagg result  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #3860: xpath crashes backend when is querying xmlagg result
List pgsql-bugs
Tom Lane escribió:

> One thing I was wondering about earlier today is whether libxml isn't
> expecting NULL-return-on-failure from the malloc-substitute routine.
> If we take control away from it unexpectedly, I wouldn't be a bit
> surprised if its data structures are left corrupt.  This might lead to
> failures during cleanup.

Hmm, this is a very good point.  I quick look at the source shows that
they are not very consistent on its own checking for memory allocation
errors.  For example, see a bug I just reported:

http://bugzilla.gnome.org/show_bug.cgi?id=508662

The problem is that many routines look like this:

xmlXPathNewNodeSet(xmlNodePtr val) {
    xmlXPathObjectPtr ret;

    ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
    if (ret == NULL) {
        xmlXPathErrMemory(NULL, "creating nodeset\n");
        return(NULL);
    }


and others would call this code and then happily use the return value
without checking for null.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3860: xpath crashes backend when is querying xmlagg result
Next
From: Tom Lane
Date:
Subject: Re: BUG #3860: xpath crashes backend when is querying xmlagg result