Skip to content

Commit 0edef16

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 f10a20e commit 0edef16

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
@@ -1697,7 +1697,10 @@ xml_errorHandler(void *data, xmlErrorPtr error)
16971697
appendStringInfo(errorBuf, "line %d: ", error->line);
16981698
if (name != NULL)
16991699
appendStringInfo(errorBuf, "element %s: ", name);
1700-
appendStringInfoString(errorBuf, error->message);
1700+
if (error->message != NULL)
1701+
appendStringInfoString(errorBuf, error->message);
1702+
else
1703+
appendStringInfoString(errorBuf, "(no message provided)");
17011704

17021705
/*
17031706
* Append context information to errorBuf.

0 commit comments

Comments
 (0)