pgsql: Don't test already-referenced pointer for nullness

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема pgsql: Don't test already-referenced pointer for nullness
Дата
Msg-id E1rPhe3-001fwA-DJ@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Don't test already-referenced pointer for nullness

Commit b8ba7344e9eb added in PQgetResult a derefence to a pointer
returned by pqPrepareAsyncResult(), before some other code that was
already testing that pointer for nullness.  But since commit
618c16707a6d (in Postgres 15), pqPrepareAsyncResult() doesn't ever
return NULL (a statically-allocated result is returned if OOM).  So in
branches 15 and up, we can remove the redundant pointer check with no
harm done.

However, in branch 14, pqPrepareAsyncResult() can indeed return NULL if
it runs out of memory.  Fix things there by adding a null pointer check
before dereferencing the pointer.  This should hint Coverity that the
preexisting check is not redundant but necessary.

Backpatch to 14, like b8ba7344e9eb.

Per Coverity.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c6605c1bdf07e8fc026bf857d37628cbb5746bb8

Modified Files
--------------
src/interfaces/libpq/fe-exec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: doc: Decorate PostgreSQL with productname tag
Следующее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: struct XmlTableRoutine: use C99 designated initializers