Skip to content

Commit cc16d26

Browse files
committed
PATCH: [perl #134059] panic outputting a warning
This was due to a logic error on my part. We need to save and restore a value. Instead, it was getting restored to the wrong value. This particular instance of the bug was outputting a fatal error message, so that the only harm is not giving the user the correct info, and creating unnecessary work for them and us when it gets reported. But this bug could manifest itself when trying to output just a warning that the program otherwise would carry on from.
1 parent d38c72a commit cc16d26

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

regcomp.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ struct RExC_state_t {
131131
char *parse; /* Input-scan pointer. */
132132
char *copy_start; /* start of copy of input within
133133
constructed parse string */
134+
char *save_copy_start; /* Provides one level of saving
135+
and restoring 'copy_start' */
134136
char *copy_start_in_input; /* Position in input string
135137
corresponding to copy_start */
136138
SSize_t whilem_seen; /* number of WHILEM in this expr */
@@ -229,6 +231,7 @@ struct RExC_state_t {
229231
#define RExC_precomp (pRExC_state->precomp)
230232
#define RExC_copy_start_in_input (pRExC_state->copy_start_in_input)
231233
#define RExC_copy_start_in_constructed (pRExC_state->copy_start)
234+
#define RExC_save_copy_start_in_constructed (pRExC_state->save_copy_start)
232235
#define RExC_precomp_end (pRExC_state->precomp_end)
233236
#define RExC_rx_sv (pRExC_state->rx_sv)
234237
#define RExC_rx (pRExC_state->rx)
@@ -821,8 +824,13 @@ static const scan_data_t zero_scan_data = {
821824
} STMT_END
822825

823826
/* Setting this to NULL is a signal to not output warnings */
824-
#define TURN_OFF_WARNINGS_IN_SUBSTITUTE_PARSE RExC_copy_start_in_constructed = NULL
825-
#define RESTORE_WARNINGS RExC_copy_start_in_constructed = RExC_precomp
827+
#define TURN_OFF_WARNINGS_IN_SUBSTITUTE_PARSE \
828+
STMT_START { \
829+
RExC_save_copy_start_in_constructed = RExC_copy_start_in_constructed;\
830+
RExC_copy_start_in_constructed = NULL; \
831+
} STMT_END
832+
#define RESTORE_WARNINGS \
833+
RExC_copy_start_in_constructed = RExC_save_copy_start_in_constructed
826834

827835
/* Since a warning can be generated multiple times as the input is reparsed, we
828836
* output it the first time we come to that point in the parse, but suppress it

t/re/reg_mesg.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ my @death =
318318
'/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/',
319319
'/\x{100}(?(/' => 'Unknown switch condition (?(...)) {#} m/\\x{100}(?({#}/', # [perl #133896]
320320
'/(?[\N{KEYCAP DIGIT NINE}/' => '\N{} in inverted character class or as a range end-point is restricted to one character {#} m/(?[\\N{U+39.FE0F.20E3{#}}/', # [perl #133988]
321+
'/0000000000000000[\N{U+0.00}0000/' => 'Unmatched [ {#} m/0000000000000000[{#}\N{U+0.00}0000/', # [perl #134059]
321322
);
322323

323324
# These are messages that are death under 'use re "strict"', and may or may

0 commit comments

Comments
 (0)