Re: Clang 3.3 Analyzer Results

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Clang 3.3 Analyzer Results
Дата
Msg-id 8303.1384275601@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Clang 3.3 Analyzer Results  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
Kevin Grittner <kgrittn@ymail.com> writes:
> Kevin Grittner <kgrittn@ymail.com> wrote:
>> Memory Error
>> �� Double free:� 1
>> �� Memory leak:� 1

> These both seemed legitimate to me.� Patch attached.� Any
> objections to applying it?� I realize the memory leak is a tiny one
> in the regression testing code, so it could never amount to enough
> to matter; but it seems worth fixing just to avoid noise in code
> analyzers.

The logic, if you can call it that, in streamutil.c makes my head hurt.
I think it needs more work than what you did here --- for one thing,
the free(password) call results in values[i] becoming a dangling pointer
to freed memory, and it's not exactly obvious that that pointer will get
overwritten again before it's used.

Moreover, although the apparent intention of the dbpassword static state
is to allow a password to be saved and reused across calls, it kinda looks
like that's broken by the odd choice to make dbgetpassword also static.
At the very least that choice makes it a lot harder to analyze what will
happen in calls after the first.

I think the looping to get a password here should be thrown out and
rewritten from scratch, or at least cribbed from someplace with less
contorted logic.
        regards, tom lane



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Errors on missing pg_subtrans/ files with 9.3
Следующее
От: Kohei KaiGai
Дата:
Сообщение: Re: What's needed for cache-only table scan?