After
d0aa965c0a0ac2ff7906ae1b1dad50a7952efa56, one error path in
PLy_spi_execute_fetch_result() could result in the variable "result"
being dereferenced after being set to NULL. To fix that, just clear the
resources right there and return early.
Also add another SPI_freetuptable() call so that that is cleared in all
error paths.
discovered by John Naylor <jcnaylor@gmail.com> via scan-build
result = (PLyResultObject *) PLy_result_new();
if (!result)
+ {
+ SPI_freetuptable(tuptable);
return NULL;
+ }
Py_DECREF(result->status);
result->status = PyInt_FromLong(status);
if (!result->rows)
{
Py_DECREF(result);
- result = NULL;
+ MemoryContextDelete(cxt);
+ SPI_freetuptable(tuptable);
+ return NULL;
}
else
{