mirror of
https://github.com/zebrajr/postgres.git
synced 2025-12-06 12:20:15 +01:00
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
59f47fb98d.
Per report from Coverity, with extra input from Tom Lane.
This commit is contained in:
parent
1f9e3a9be5
commit
f19669fed3
|
|
@ -238,7 +238,7 @@ initTrie(const char *filename)
|
||||||
if (trgquoted && state > 0)
|
if (trgquoted && state > 0)
|
||||||
{
|
{
|
||||||
/* Ignore first and end quotes */
|
/* Ignore first and end quotes */
|
||||||
trgstore = palloc0(sizeof(char *) * trglen - 2);
|
trgstore = (char *) palloc(sizeof(char) * (trglen - 2));
|
||||||
trgstorelen = 0;
|
trgstorelen = 0;
|
||||||
for (int i = 1; i < trglen - 1; i++)
|
for (int i = 1; i < trglen - 1; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -251,7 +251,7 @@ initTrie(const char *filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trgstore = palloc0(sizeof(char *) * trglen);
|
trgstore = (char *) palloc(sizeof(char) * trglen);
|
||||||
trgstorelen = trglen;
|
trgstorelen = trglen;
|
||||||
memcpy(trgstore, trg, trgstorelen);
|
memcpy(trgstore, trg, trgstorelen);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user