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

Commit77ae7f7

Browse files
committed
Plug memory leak in range_cmp function.
B-tree operators are not allowed to leak memory into the current memorycontext. Range_cmp leaked detoasted copies of the arguments. That causeda quick out-of-memory error when creating an index on a range column.Reported by Marian Krucina, bug #8468.
1 parentb2fc4d6 commit77ae7f7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/backend/utils/adt/rangetypes.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,16 +1125,22 @@ range_cmp(PG_FUNCTION_ARGS)
11251125

11261126
/* For b-tree use, empty ranges sort before all else */
11271127
if (empty1&&empty2)
1128-
PG_RETURN_INT32(0);
1128+
cmp=0;
11291129
elseif (empty1)
1130-
PG_RETURN_INT32(-1);
1130+
cmp=-1;
11311131
elseif (empty2)
1132-
PG_RETURN_INT32(1);
1132+
cmp=1;
1133+
else
1134+
{
1135+
cmp=range_cmp_bounds(typcache,&lower1,&lower2);
1136+
if (cmp==0)
1137+
cmp=range_cmp_bounds(typcache,&upper1,&upper2);
1138+
}
11331139

1134-
if ((cmp=range_cmp_bounds(typcache,&lower1,&lower2))!=0)
1135-
PG_RETURN_INT32(cmp);
1140+
PG_FREE_IF_COPY(r1,0);
1141+
PG_FREE_IF_COPY(r2,1);
11361142

1137-
PG_RETURN_INT32(range_cmp_bounds(typcache,&upper1,&upper2));
1143+
PG_RETURN_INT32(cmp);
11381144
}
11391145

11401146
/* inequality operators using the range_cmp function */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp