Re: pg 8.3.7 libxml trying to free NULL pointer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sergey Burladyan <eshkinkot(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: pg 8.3.7 libxml trying to free NULL pointer
Date: 2009-06-10 02:20:37
Message-ID: 4762.1244600437@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sergey Burladyan <eshkinkot(at)gmail(dot)com> writes:
> postgres=# select xpath('count(//)', '<a></a>'::xml);
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.

Hmm. Looking at the libxml2 source code makes it clear that at least
this one function (xmlXPathCompFunctionCall) needs xmlFree(NULL) to be a
no-op, because it's not checking. I don't know whether the libxml guys
would consider that a bug or not. Their API specifications are so poor
that one can't really tell if an xmlFree callback is supposed to allow
NULL or not. The wording of
http://xmlsoft.org/html/libxml-xmlmemory.html#xmlFreeFunc suggests not,
and since we've not seen this before, there's at least fairly large
sections of libxml that do not assume they can free(NULL).

Anyway, I suppose the most prudent thing to do is assume that xml_pfree
had better act like POSIX free() and allow NULL, because it's unlikely
they test their code with any other implementation ...

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniele Bortoluzzi 2009-06-10 06:38:49 Re: BUG #4838: Database corruption after btree_gin index creation
Previous Message Sergey Burladyan 2009-06-10 02:10:54 Re: pg 8.3.7 libxml trying to free NULL pointer