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

Commite13ac55

Browse files
committed
Avoid possible crash in contrib/bloom's blendscan().
It's possible to begin and end an indexscan without ever callingamrescan. contrib/bloom, unlike every other index AM, allocatedits "scan->opaque" storage at amrescan time, and thus would crashin amendscan if amrescan hadn't been called. We could fix thisby putting in a null-pointer check in blendscan, but I see no verygood reason why contrib/bloom should march to its own drummer inthis respect. Let's move that initialization to blbeginscaninstead. Per report from Jeff Janes.
1 parent7c979c9 commite13ac55

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

‎contrib/bloom/blscan.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ IndexScanDesc
2929
blbeginscan(Relationr,intnkeys,intnorderbys)
3030
{
3131
IndexScanDescscan;
32+
BloomScanOpaqueso;
3233

3334
scan=RelationGetIndexScan(r,nkeys,norderbys);
3435

36+
so= (BloomScanOpaque)palloc(sizeof(BloomScanOpaqueData));
37+
initBloomState(&so->state,scan->indexRelation);
38+
so->sign=NULL;
39+
40+
scan->opaque=so;
41+
3542
returnscan;
3643
}
3744

@@ -42,23 +49,10 @@ void
4249
blrescan(IndexScanDescscan,ScanKeyscankey,intnscankeys,
4350
ScanKeyorderbys,intnorderbys)
4451
{
45-
BloomScanOpaqueso;
46-
47-
so= (BloomScanOpaque)scan->opaque;
48-
49-
if (so==NULL)
50-
{
51-
/* if called from blbeginscan */
52-
so= (BloomScanOpaque)palloc(sizeof(BloomScanOpaqueData));
53-
initBloomState(&so->state,scan->indexRelation);
54-
scan->opaque=so;
52+
BloomScanOpaqueso= (BloomScanOpaque)scan->opaque;
5553

56-
}
57-
else
58-
{
59-
if (so->sign)
60-
pfree(so->sign);
61-
}
54+
if (so->sign)
55+
pfree(so->sign);
6256
so->sign=NULL;
6357

6458
if (scankey&&scan->numberOfKeys>0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp