diff options
| author | Noah Misch | 2015-02-26 04:48:28 +0000 |
|---|---|---|
| committer | Noah Misch | 2015-02-26 04:48:58 +0000 |
| commit | d7083cc546bba50fe1adea5a05772f857cbff96b (patch) | |
| tree | 9e16ab074c1497db05ff34ae4183c1438dd92791 /src/pl | |
| parent | be8801e9c5f86122dacc8b037f0fab960dc0b196 (diff) | |
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.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index dc3bcfe37a9..6f4fe918596 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -1129,8 +1129,9 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) { /* * Initialize the magic SQLSTATE and SQLERRM variables for - * the exception block. We needn't do this until we have - * found a matching exception. + * the exception block; this also frees values from any + * prior use of the same exception. We needn't do this + * until we have found a matching exception. */ PLpgSQL_var *state_var; PLpgSQL_var *errm_var; @@ -1154,13 +1155,6 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) rc = exec_stmts(estate, exception->action); - free_var(state_var); - state_var->value = (Datum) 0; - state_var->isnull = true; - free_var(errm_var); - errm_var->value = (Datum) 0; - errm_var->isnull = true; - break; } } |
