pgsql: Fix assorted small bugs in ThrowErrorData().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix assorted small bugs in ThrowErrorData().
Date: 2016-08-26 18:19:17
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix assorted small bugs in ThrowErrorData().

Copy the palloc'd strings into the correct context, ie ErrorContext
not wherever the source ErrorData is. This would be a large bug,
except that it appears that all catchers of thrown errors do either
EmitErrorReport or CopyErrorData before doing anything that would
cause transient memory contexts to be cleaned up. Still, it's wrong
and it will bite somebody someday.

Fix failure to copy cursorpos and internalpos.

Utter the appropriate incantations involving recursion_depth, so that
we'll behave sanely if we get an error inside pstrdup. (In general,
the body of this function ought to act like, eg, errdetail().)

Per code reading induced by Jakob Egger's report.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/51b5008c7fdbdc762ce2103c1d907278c0882909

Modified Files
--------------
src/backend/utils/error/elog.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-08-26 19:04:26 pgsql: Fix potential memory leakage from HandleParallelMessages().
Previous Message Tom Lane 2016-08-26 14:07:40 pgsql: Fix logic for adding "parallel worker" context line to worker er