Skip to content

Commit 4eb7571

Browse files
michaelpqpull[bot]
authored andcommitted
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 59f47fb. Per report from Coverity, with extra input from Tom Lane.
1 parent b59c2b0 commit 4eb7571

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

contrib/unaccent/unaccent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ initTrie(const char *filename)
238238
if (trgquoted && state > 0)
239239
{
240240
/* Ignore first and end quotes */
241-
trgstore = palloc0(sizeof(char *) * trglen - 2);
241+
trgstore = (char *) palloc(sizeof(char) * (trglen - 2));
242242
trgstorelen = 0;
243243
for (int i = 1; i < trglen - 1; i++)
244244
{
@@ -251,7 +251,7 @@ initTrie(const char *filename)
251251
}
252252
else
253253
{
254-
trgstore = palloc0(sizeof(char *) * trglen);
254+
trgstore = (char *) palloc(sizeof(char) * trglen);
255255
trgstorelen = trglen;
256256
memcpy(trgstore, trg, trgstorelen);
257257
}

0 commit comments

Comments
 (0)