Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92375ed

Browse files
committed
Fix bogus code in contrib/ tsearch dictionary examples.
Both dict_int and dict_xsyn were blithely assuming that whatever memorypalloc gives back will be pre-zeroed. This would typically work forjust about long enough to run their regression tests, and no longer :-(.The pre-9.0 code in dict_xsyn was even lamer than that, as it wouldhappily give back a pointer to the result of palloc(0), encouragingits caller to access off the end of memory. Again, this would justbarely fail to fail as long as memory contained nothing but zeroes.Per a report from Rodrigo Hjort that code based on these examplesdidn't work reliably.
1 parent1819a37 commit92375ed

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

‎contrib/dict_int/dict_int.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dintdict_lexize(PG_FUNCTION_ARGS)
7373
DictInt*d= (DictInt*)PG_GETARG_POINTER(0);
7474
char*in= (char*)PG_GETARG_POINTER(1);
7575
char*txt=pnstrdup(in,PG_GETARG_INT32(2));
76-
TSLexeme*res=palloc(sizeof(TSLexeme)*2);
76+
TSLexeme*res=palloc0(sizeof(TSLexeme)*2);
7777

7878
res[1].lexeme=NULL;
7979
if (PG_GETARG_INT32(2)>d->maxlen)

‎contrib/dict_xsyn/dict_xsyn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ dxsyn_lexize(PG_FUNCTION_ARGS)
245245
if (pos!=value||d->keeporig)
246246
{
247247
res[nsyns].lexeme=pnstrdup(syn,end-syn);
248+
res[nsyns].nvariant=0;
249+
res[nsyns].flags=0;
248250
nsyns++;
249251
}
250252

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp