pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Don't test already-referenced pointer for nullness 4+ messages / 1 participants [nested] [flat]
* pgsql: Don't test already-referenced pointer for nullness @ 2024-01-16 11:30 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2024-01-16 11:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/39aab11085177e4026cec6065a78a425c44e23e3 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Don't test already-referenced pointer for nullness @ 2024-01-16 11:30 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2024-01-16 11:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Don't test already-referenced pointer for nullness @ 2024-01-16 11:30 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2024-01-16 11:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2b656cbd2f24edb7e2964fa3f71ca253ee9d81d8 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Don't test already-referenced pointer for nullness @ 2024-01-16 11:30 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2024-01-16 11:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7a7c8c98a610418ed0118e22a1793bf27e55783a Modified Files -------------- src/interfaces/libpq/fe-exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-01-16 11:30 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-01-16 11:30 pgsql: Don't test already-referenced pointer for nullness Alvaro Herrera <alvherre@alvh.no-ip.org> 2024-01-16 11:30 pgsql: Don't test already-referenced pointer for nullness Alvaro Herrera <alvherre@alvh.no-ip.org> 2024-01-16 11:30 pgsql: Don't test already-referenced pointer for nullness Alvaro Herrera <alvherre@alvh.no-ip.org> 2024-01-16 11:30 pgsql: Don't test already-referenced pointer for nullness Alvaro Herrera <alvherre@alvh.no-ip.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox