Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1bc2f0

Browse files
committed
Fix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
memory if the result had zero rows, and also if there was any sort of errorwhile converting the result tuples into Python data. Reported and partiallyfixed by Andres Freund.Back-patch to all supported versions. Note: I haven't tested the 7.4 fix.7.4's configure check for python is so obsolete it doesn't work on mycurrent machines :-(. The logic change is pretty straightforward though.
1 parent0954358 commitb1bc2f0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎src/pl/plpython/plpython.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
4-
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.141 2010/03/18 19:43:03 petere Exp $
4+
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.142 2010/04/30 19:15:45 tgl Exp $
55
*
66
*********************************************************************
77
*/
@@ -3147,9 +3147,6 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
31473147

31483148
PyList_SetItem(result->rows,i,row);
31493149
}
3150-
PLy_typeinfo_dealloc(&args);
3151-
3152-
SPI_freetuptable(tuptable);
31533150
}
31543151
}
31553152
PG_CATCH();
@@ -3160,11 +3157,15 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
31603157
if (!PyErr_Occurred())
31613158
PLy_exception_set(PLy_exc_error,
31623159
"unrecognized error in PLy_spi_execute_fetch_result");
3163-
Py_DECREF(result);
31643160
PLy_typeinfo_dealloc(&args);
3161+
SPI_freetuptable(tuptable);
3162+
Py_DECREF(result);
31653163
returnNULL;
31663164
}
31673165
PG_END_TRY();
3166+
3167+
PLy_typeinfo_dealloc(&args);
3168+
SPI_freetuptable(tuptable);
31683169
}
31693170

31703171
return (PyObject*)result;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp