Re: pgsql: PL/Python: Fix potential NULL pointer dereference
От | Tom Lane |
---|---|
Тема | Re: pgsql: PL/Python: Fix potential NULL pointer dereference |
Дата | |
Msg-id | 16695.1512503159@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: pgsql: PL/Python: Fix potential NULL pointer dereference (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>) |
Ответы |
Re: pgsql: PL/Python: Fix potential NULL pointer dereference
|
Список | pgsql-committers |
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes: > On 11/28/17 13:35, Peter Eisentraut wrote: >> OK, I'll revert and rethink. > How about this instead? This looks better, but I think there are a couple more things: * Seems like you ought to s/Py_DECREF(result)/Py_XDECREF(result)/ in the PG_CATCH block (line 451 in HEAD). As this is coded, although result is set to NULL within the PG_TRY, it doesn't seem possible for control to reach PG_CATCH after that ... but that's a pretty fragile assumption. * You'd also need to declare "result" as PLyResultObject *volatile result; if you intend to change it within the PG_TRY block. On the whole it seems like it might be better to dodge this whole business of changing "result" inside the TRY. You could do that if you did something like result->rows = PyList_New(rows); - if (!result->rows) - { - Py_DECREF(result); - result = NULL; - } - else + if (result->rows) { PLy_input_setup_tuple(&ininfo, tuptable->tupdesc, and then add after the PG_END_TRY if (!result->rows) { Py_DECREF(result); result = NULL; } The repeated test is a bit annoying but maybe it's better than the alternative. You'd probably need a comment explaining why it's like that, though. regards, tom lane
В списке pgsql-committers по дате отправления: