postgres.git / summary / log / commit / refs

commit    ef922faea703aff4996eab17520cb5201a793701
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Fri Feb 08 18:30:42 2019 +0000
First released in: 12.0, 9.4.21, 9.5.16, 9.6.12, 10.7, 11.2

    Defend against null error message reported by libxml2.
    
    While this isn't really supposed to happen, it can occur in OOM
    situations and perhaps others.  Instead of crashing, substitute
    "(no message provided)".
    
    I didn't worry about localizing this text, since we aren't
    localizing anything else here; besides, if we're on the edge of
    OOM, it's unlikely gettext() would work.
    
    Report and fix by Sergio Conde Gómez in bug #15624.
    
    Discussion: https://postgr.es/m/15624-4dea54091a2864e6@postgresql.org


src/backend/utils/adt/xml.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 8253e508fc6..0309fdde9af 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -1638,7 +1638,10 @@ xml_errorHandler(void *data, xmlErrorPtr error) appendStringInfo(errorBuf, "line %d: ", error->line); if (name != NULL) appendStringInfo(errorBuf, "element %s: ", name); - appendStringInfoString(errorBuf, error->message); + if (error->message != NULL) + appendStringInfoString(errorBuf, error->message); + else + appendStringInfoString(errorBuf, "(no message provided)"); /* * Append context information to errorBuf. [parent: 2bcbf687e426]