diff options
-rw-r--r-- | contrib/xml2/xpath.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index 25cc7f9377b..51069adfc52 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -100,9 +100,20 @@ elog_error(const char *explain, bool force) (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("%s", explain))); else + { + /* + * Ensure pgxml_errorMsg is reset to null before we give up + * control. This provides some protection against crashes if + * pgxml_errorHandler is invoked again later, perhaps as a + * result of other modules' use of libxml. + */ + char *msg = pgxml_errorMsg; + + pgxml_errorMsg = NULL; ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), - errmsg("%s: %s", explain, pgxml_errorMsg))); + errmsg("%s: %s", explain, msg))); + } } } |