aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/xml.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-02-08 13:30:42 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-02-08 13:30:57 -0500
commit8e2956734b98933f833c7845da724c7a6d98341d (patch)
tree5e1cf02d32a16b6a88d827d2ebddf188becbd4e0 /src/backend/utils/adt/xml.c
parent8cf3fada2f87f2cbd0102389bf59434b45e911fe (diff)
downloadpostgresql-8e2956734b98933f833c7845da724c7a6d98341d.tar.gz
postgresql-8e2956734b98933f833c7845da724c7a6d98341d.zip
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
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r--src/backend/utils/adt/xml.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 37d85f71f3b..2bd118c0ef5 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -1696,7 +1696,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.