diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-09-25 09:31:48 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-09-25 09:31:48 +0900 |
commit | f19669fed3efe872425c80d4b1f45bf59267b7ea (patch) | |
tree | 362597824a99d7730426ac8093ee6f6fd8d70b16 | |
parent | 1f9e3a9be539f912babd3ad58d01a4ce6aa0b85b (diff) | |
download | postgresql-f19669fed3efe872425c80d4b1f45bf59267b7ea.tar.gz postgresql-f19669fed3efe872425c80d4b1f45bf59267b7ea.zip |
unaccent: Fix allocation size for target characters on initial load
This led to an overestimation of the size allocated for both the quoted
and non-quoted cases, while using an inconsistent style. Thinkos in
59f47fb98dab.
Per report from Coverity, with extra input from Tom Lane.
-rw-r--r-- | contrib/unaccent/unaccent.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index 5635f042145..544246e37f1 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -238,7 +238,7 @@ initTrie(const char *filename) if (trgquoted && state > 0) { /* Ignore first and end quotes */ - trgstore = palloc0(sizeof(char *) * trglen - 2); + trgstore = (char *) palloc(sizeof(char) * (trglen - 2)); trgstorelen = 0; for (int i = 1; i < trglen - 1; i++) { @@ -251,7 +251,7 @@ initTrie(const char *filename) } else { - trgstore = palloc0(sizeof(char *) * trglen); + trgstore = (char *) palloc(sizeof(char) * trglen); trgstorelen = trglen; memcpy(trgstore, trg, trgstorelen); } |