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

Commite3e3087

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 parenta0d2f05 commite3e3087

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
@@ -72,7 +72,7 @@ dintdict_lexize(PG_FUNCTION_ARGS)
7272
DictInt*d= (DictInt*)PG_GETARG_POINTER(0);
7373
char*in= (char*)PG_GETARG_POINTER(1);
7474
char*txt=pnstrdup(in,PG_GETARG_INT32(2));
75-
TSLexeme*res=palloc(sizeof(TSLexeme)*2);
75+
TSLexeme*res=palloc0(sizeof(TSLexeme)*2);
7676

7777
res[1].lexeme=NULL;
7878
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
@@ -244,6 +244,8 @@ dxsyn_lexize(PG_FUNCTION_ARGS)
244244
if (pos!=value||d->keeporig)
245245
{
246246
res[nsyns].lexeme=pnstrdup(syn,end-syn);
247+
res[nsyns].nvariant=0;
248+
res[nsyns].flags=0;
247249
nsyns++;
248250
}
249251

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp