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

Commit0c7d3bb

Browse files
committed
Add missing array-enlargement logic to test_regex.c.
The stanza to report a "partial" match could overrun the initiallyallocated output array, so it needs its own copy of the array-resizinglogic that's in the main loop. I overlooked the need for this inca8217c.Per report from Alexander Lakhin.Discussion:https://postgr.es/m/3206aace-50db-e02a-bbea-76d5cdaa2cb6@gmail.com
1 parentcf621d9 commit0c7d3bb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎src/test/modules/test_regex/test_regex.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@ setup_test_matches(text *orig_str,
555555
*/
556556
if (matchctx->nmatches==0&&re_flags->partial&&re_flags->indices)
557557
{
558+
/* enlarge output space if needed */
559+
while (array_idx+matchctx->npatterns*2+1>array_len)
560+
{
561+
array_len+=array_len+1;/* 2^n-1 => 2^(n+1)-1 */
562+
if (array_len>MaxAllocSize /sizeof(int))
563+
ereport(ERROR,
564+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
565+
errmsg("too many regular expression matches")));
566+
matchctx->match_locs= (int*)repalloc(matchctx->match_locs,
567+
sizeof(int)*array_len);
568+
}
569+
558570
matchctx->match_locs[array_idx++]=matchctx->details.rm_extend.rm_so;
559571
matchctx->match_locs[array_idx++]=matchctx->details.rm_extend.rm_eo;
560572
/* we don't have pmatch data, so emit -1 */
@@ -566,6 +578,8 @@ setup_test_matches(text *orig_str,
566578
matchctx->nmatches++;
567579
}
568580

581+
Assert(array_idx <=array_len);
582+
569583
if (eml>1)
570584
{
571585
int64maxsiz=eml* (int64)maxlen;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp