@@ -63,7 +63,7 @@ typedef struct regexp_matches_ctx
63
63
Datum * elems ; /* has npatterns elements */
64
64
bool * nulls ; /* has npatterns elements */
65
65
pg_wchar * wide_str ; /* wide-char version of original string */
66
- char * conv_buf ; /* conversion buffer */
66
+ char * conv_buf ; /* conversion buffer, if needed */
67
67
int conv_bufsiz ; /* size thereof */
68
68
} regexp_matches_ctx ;
69
69
@@ -1285,7 +1285,6 @@ static ArrayType *
1285
1285
build_regexp_match_result (regexp_matches_ctx * matchctx )
1286
1286
{
1287
1287
char * buf = matchctx -> conv_buf ;
1288
- int bufsiz PG_USED_FOR_ASSERTS_ONLY = matchctx -> conv_bufsiz ;
1289
1288
Datum * elems = matchctx -> elems ;
1290
1289
bool * nulls = matchctx -> nulls ;
1291
1290
int dims [1 ];
@@ -1311,7 +1310,7 @@ build_regexp_match_result(regexp_matches_ctx *matchctx)
1311
1310
buf ,
1312
1311
eo - so );
1313
1312
1314
- Assert (len < bufsiz );
1313
+ Assert (len < matchctx -> conv_bufsiz );
1315
1314
elems [i ] = PointerGetDatum (cstring_to_text_with_len (buf , len ));
1316
1315
nulls [i ] = false;
1317
1316
}
@@ -1467,25 +1466,22 @@ build_regexp_split_result(regexp_matches_ctx *splitctx)
1467
1466
if (startpos < 0 )
1468
1467
elog (ERROR , "invalid match ending position" );
1469
1468
1469
+ endpos = splitctx -> match_locs [splitctx -> next_match * 2 ];
1470
+ if (endpos < startpos )
1471
+ elog (ERROR , "invalid match starting position" );
1472
+
1470
1473
if (buf )
1471
1474
{
1472
- int bufsiz PG_USED_FOR_ASSERTS_ONLY = splitctx -> conv_bufsiz ;
1473
1475
int len ;
1474
1476
1475
- endpos = splitctx -> match_locs [splitctx -> next_match * 2 ];
1476
- if (endpos < startpos )
1477
- elog (ERROR , "invalid match starting position" );
1478
1477
len = pg_wchar2mb_with_len (splitctx -> wide_str + startpos ,
1479
1478
buf ,
1480
1479
endpos - startpos );
1481
- Assert (len < bufsiz );
1480
+ Assert (len < splitctx -> conv_bufsiz );
1482
1481
return PointerGetDatum (cstring_to_text_with_len (buf , len ));
1483
1482
}
1484
1483
else
1485
1484
{
1486
- endpos = splitctx -> match_locs [splitctx -> next_match * 2 ];
1487
- if (endpos < startpos )
1488
- elog (ERROR , "invalid match starting position" );
1489
1485
return DirectFunctionCall3 (text_substr ,
1490
1486
PointerGetDatum (splitctx -> orig_str ),
1491
1487
Int32GetDatum (startpos + 1 ),
0 commit comments