Re: BUG #15624: Sefgault when xml_errorHandler receives a null error->message from libxml2

Sergio Conde Gómez <skgsergio@gmail.com>

From: Sergio Conde Gómez <skgsergio@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2019-02-08T18:00:46Z
Lists: pgsql-bugs
Yes, you are right. Didn't really checked the full output so it makes sense
to do that to be consistent as almost always there will be a message.
Thanks!

El vie., 8 feb. 2019 a las 18:53, Tom Lane (<tgl@sss.pgh.pa.us>) escribió:

> PG Bug reporting form <noreply@postgresql.org> writes:
> > Although libxml2 tries not to return a null message but both their
> xmlStrdup
> > function and XML_GET_VAR_STR can return null in a OOM scenario.
>
> Ugh.
>
> > -     appendStringInfoString(errorBuf, error->message);
> > +     if (error->message != NULL)
> > +             appendStringInfoString(errorBuf, error->message);
>
> I'm inclined to do something more like
>
> +       if (error->message != NULL)
> +               appendStringInfoString(errorBuf, error->message);
> +       else
> +               appendStringInfoString(errorBuf, "(no message provided)");
>
> else the output will read very oddly in this situation.
>
> Thanks for the report!
>
>                         regards, tom lane
>


-- 
Sergio Conde
GPG Key: 0x1867A20A
Fingerprint: 487D 62C8 523C 9BBF 7CC8 D029 959E A15D 1867 A20A
http://keybase.io/skgsergio

Commits

  1. Defend against null error message reported by libxml2.