pgsql: Use Size rather than int for storing strnlen's return

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use Size rather than int for storing strnlen's return
Date: 2026-10-21 00:33:00
Message-ID: E1xJKGK-000000004ux-1vyo@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use Size rather than int for storing strnlen's return

... in fe_memutils.c's pnstrdup().

strnlen() does return size_t, so it seems better to use the Size input
parameter to store the return value rather than demote it to int and
risk larger values being truncated.

Pushing only to master as this doesn't seem like an actual problem.
Fixing will hopefully prevent future LLM-triggered reports about this.

Author: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/0E717E09-809F-4BC4-B3B1-36BE729DBFAE@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/38c3d87d43397ab600f085e398789f3dea1cd0a5

Modified Files
--------------
src/common/fe_memutils.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-10-21 01:56:12 pgsql: Fix cleanup of reused pgstats entries in pgstat_release_entry_re
Previous Message Tom Lane 2026-10-20 22:49:53 pgsql: Fix cross-version upgrade tests for commits 0497318e4 et al.