Commit 581a5588 authored by Peter Eisentraut's avatar Peter Eisentraut

Fix nested error handling in PG_FINALLY

We need to pop the error stack before running the user-supplied
PG_FINALLY code.  Otherwise an error in the cleanup code would end up
at the same sigsetjmp() invocation and result in an infinite error
handling loop.
Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/95a822c3-728b-af0e-d7e5-71890507ae0c%402ndquadrant.com
parent a0c96856
...@@ -3868,7 +3868,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt) ...@@ -3868,7 +3868,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt)
result = xmlBuffer_to_xmltype(buf); result = xmlBuffer_to_xmltype(buf);
} }
PG_FINALLY() PG_FINALLY();
{ {
if (nodefree) if (nodefree)
nodefree(cur_copy); nodefree(cur_copy);
......
...@@ -338,14 +338,16 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack; ...@@ -338,14 +338,16 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
} \ } \
else \ else \
_do_rethrow = true; \ _do_rethrow = true; \
{ { \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack
#define PG_END_TRY() \ #define PG_END_TRY() \
} \ } \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack; \
if (_do_rethrow) \ if (_do_rethrow) \
PG_RE_THROW(); \ PG_RE_THROW(); \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack; \
} while (0) } while (0)
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment