v1-0002-Fix-callers-of-unicode_strtitle-using-srclen-1.patch
text/x-patch
Filename: v1-0002-Fix-callers-of-unicode_strtitle-using-srclen-1.patch
Type: text/x-patch
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0002
Subject: Fix callers of unicode_strtitle() using srclen == -1.
| File | + | − |
|---|---|---|
| src/backend/utils/adt/pg_locale_builtin.c | 1 | 1 |
| src/common/unicode/case_test.c | 1 | 1 |
From b104c64e5572b04622c11883d2a82e579d134944 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
Date: Thu, 16 Apr 2026 16:20:02 -0700
Subject: [PATCH v1 2/2] Fix callers of unicode_strtitle() using srclen == -1.
Currently, only called that way in tests, which failed to fail.
Backpatch-through: 18
---
src/backend/utils/adt/pg_locale_builtin.c | 2 +-
src/common/unicode/case_test.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/pg_locale_builtin.c b/src/backend/utils/adt/pg_locale_builtin.c
index b5aeb7a337a..794aa37df76 100644
--- a/src/backend/utils/adt/pg_locale_builtin.c
+++ b/src/backend/utils/adt/pg_locale_builtin.c
@@ -97,7 +97,7 @@ strtitle_builtin(char *dest, size_t destsize, const char *src, ssize_t srclen,
{
struct WordBoundaryState wbstate = {
.str = src,
- .len = srclen,
+ .len = (srclen < 0) ? strlen(src) : srclen,
.offset = 0,
.posix = !locale->builtin.casemap_full,
.init = false,
diff --git a/src/common/unicode/case_test.c b/src/common/unicode/case_test.c
index e34f700d9c4..099530c1ead 100644
--- a/src/common/unicode/case_test.c
+++ b/src/common/unicode/case_test.c
@@ -304,7 +304,7 @@ tfunc_title(char *dst, size_t dstsize, const char *src,
{
struct WordBoundaryState wbstate = {
.str = src,
- .len = srclen,
+ .len = (srclen < 0) ? strlen(src) : srclen,
.offset = 0,
.init = false,
.prev_alnum = false,
--
2.43.0