Skip to content

Commit 37f3a77

Browse files
committed
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
1 parent ccae096 commit 37f3a77

File tree

1 file changed

+4
-1
lines changed
  • src/backend/utils/adt

1 file changed

+4
-1
lines changed

src/backend/utils/adt/xml.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,10 @@ xml_errorHandler(void *data, xmlErrorPtr error)
16361636
appendStringInfo(errorBuf, "line %d: ", error->line);
16371637
if (name != NULL)
16381638
appendStringInfo(errorBuf, "element %s: ", name);
1639-
appendStringInfoString(errorBuf, error->message);
1639+
if (error->message != NULL)
1640+
appendStringInfoString(errorBuf, error->message);
1641+
else
1642+
appendStringInfoString(errorBuf, "(no message provided)");
16401643

16411644
/*
16421645
* Append context information to errorBuf.

0 commit comments

Comments
 (0)