Memory leak with SQLNumResultCols

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Memory leak with SQLNumResultCols
Дата
Msg-id 5143041A.20605@vmware.com
обсуждение исходный текст
Список pgsql-odbc
If you call SQLNumResultCols() on a non-SELECT statement, e.g. INSERT
RETURNING, it leaks memory.

The root cause is that QR_Constructor() gets called multiple times due
to multiple-evaluation of macro arguments. A the end of SC_pre_execute():

>         if (!SC_is_pre_executable(self))
>         {
>             SC_set_Result(self, QR_Constructor());
>             QR_set_rstatus(SC_get_Result(self), PORES_TUPLES_OK);
>             self->inaccurate_result = TRUE;
>             self->status = STMT_PREMATURE;
>             num_fields = 0;
>         }

SC_set_Result is a macro, which evaluates the 2nd argument multiple
times, so we end up creating multiple result sets, most of which are leaked.

Multiple-evaluating macros are pretty dangerous. I think we should turn
them into proper functions, per attached patch. This doesn't change all
macros, only a few of the more complicated ones, and the one causing the
leak in particular.

The attached patch is also available at my git repository at
https://github.com/hlinnaka/psqlodbc/, along with a test case in
master-with-testcases branch.

- Heikki

Вложения

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: QR_Destructor should iterate, not recurse, chained result sets
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Migrating from CVS to git