pgsql: PL/Python: Fix potential NULL pointer dereference

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: PL/Python: Fix potential NULL pointer dereference
Date: 2017-12-13 02:03:17
Message-ID: E1eOwOD-0008JP-V8@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

PL/Python: Fix potential NULL pointer dereference

After d0aa965c0a0ac2ff7906ae1b1dad50a7952efa56, one error path in
PLy_spi_execute_fetch_result() could result in the variable "result"
being dereferenced after being set to NULL. Rearrange the code a bit to
fix that.

Also add another SPI_freetuptable() call so that that is cleared in all
error paths.

discovered by John Naylor <jcnaylor(at)gmail(dot)com> via scan-build

ideas and review by Tom Lane

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4c6744ed705df6f388371d044b87d1b4a60e9f80

Modified Files
--------------
src/pl/plpython/plpy_spi.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2017-12-13 02:21:06 pgsql: Consistently use PG_INT(16|32|64)_(MIN|MAX).
Previous Message Andres Freund 2017-12-13 01:23:07 pgsql: Make PGAC_C_BUILTIN_OP_OVERFLOW link instead of just compiling.