File tree 1 file changed +12
-6
lines changed 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ EXTERN_C const struct regexp_engine my_reg_engine;
105
105
#define MIN(a,b) ((a) < (b) ? (a) : (b))
106
106
#endif
107
107
108
+ #ifndef MAX
109
+ #define MAX(a,b) ((a) > (b) ? (a) : (b))
110
+ #endif
111
+
108
112
/* this is a chain of data about sub patterns we are processing that
109
113
need to be handled separately/specially in study_chunk. Its so
110
114
we can simulate recursion without losing state. */
@@ -8430,16 +8434,18 @@ S_invlist_set_previous_index(SV* const invlist, const IV index)
8430
8434
PERL_STATIC_INLINE void
8431
8435
S_invlist_trim(SV* invlist)
8432
8436
{
8437
+ /* Free the not currently-being-used space in an inversion list */
8438
+
8439
+ /* But don't free up the space needed for 0 UV that is always at the
8440
+ * beginning of the list, nor the trailing NUL */
8441
+ const UV min_size = TO_INTERNAL_SIZE(1) + 1;
8442
+
8433
8443
PERL_ARGS_ASSERT_INVLIST_TRIM;
8434
8444
8435
8445
assert(SvTYPE(invlist) == SVt_INVLIST);
8436
8446
8437
- /* Change the length of the inversion list to how many entries it currently
8438
- * has. But don't shorten it so that it would free up the required
8439
- * initial 0 UV (and a trailing NUL byte) */
8440
- if (SvCUR(invlist) > TO_INTERNAL_SIZE(1) + 1) {
8441
- SvPV_shrink_to_cur(invlist);
8442
- }
8447
+ SvPV_renew(invlist, MAX(min_size, SvCUR(invlist) + 1));
8448
+
8443
8449
}
8444
8450
8445
8451
PERL_STATIC_INLINE void
You can’t perform that action at this time.
0 commit comments