Free SQLSTATE and SQLERRM no earlier than other PL/pgSQL variables.
Noah Misch <noah@leadboat.com>
Free SQLSTATE and SQLERRM no earlier than other PL/pgSQL variables. "RETURN SQLERRM" prompted plpgsql_exec_function() to read from freed memory. Back-patch to 9.0 (all supported versions). Little code ran between the premature free and the read, so non-assert builds are unlikely to witness user-visible consequences.
Files
| Path | Change | +/− |
|---|---|---|
| src/pl/plpgsql/src/pl_exec.c | modified | +3 −9 |
| src/test/regress/expected/plpgsql.out | modified | +12 −0 |
| src/test/regress/sql/plpgsql.sql | modified | +9 −1 |