Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Defend against null error message reported by libxml2.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Feb 2019 18:30:42 +0000 (13:30 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Feb 2019 18:31:15 +0000 (13:31 -0500)
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

index 96f187c6ef4fc4cca16c8315cdc3d016aa0c0149..8b0d9f7181cb89dc5e9620c958625d2a67e0288f 100644 (file)
@@ -1640,7 +1640,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.