mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
Hold heredoc offsets in rb_len_t
Where rb_len_t is wider than long, a heredoc opener past column LONG_MAX made the long offset negative, and the identifier and the restored lexer position were read from before the line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f42bb946c
commit
c68782a239
2 files changed
+3
-3
Notes:
git
2026-10-13 09:30:25 +00:00
No files matched your search
+1
-1
@@ -39,7 +39,7 @@ typedef struct rb_strterm_literal_struct {
|
||||
|
||||
typedef struct rb_strterm_heredoc_struct {
|
||||
rb_parser_string_t *lastline; /* the string of line that contains `<<"END"` */
|
||||
long offset; /* the column of END in `<<"END"` */
|
||||
rb_len_t offset; /* the column of END in `<<"END"` */
|
||||
int sourceline; /* lineno of the line that contains `<<"END"` */
|
||||
unsigned length; /* the length of END in `<<"END"` */
|
||||
uint8_t quote;
|
||||
|
||||
@@ -8686,7 +8686,7 @@ heredoc_identifier(struct parser_params *p)
|
||||
* term_len is length of `<<"END"` except `END`,
|
||||
* in this case term_len is 4 (<, <, " and ").
|
||||
*/
|
||||
long len, offset = p->lex.pcur - p->lex.pbeg;
|
||||
rb_len_t len, offset = p->lex.pcur - p->lex.pbeg;
|
||||
int c = nextc(p), term, func = 0, quote = 0;
|
||||
enum yytokentype token = tSTRING_BEG;
|
||||
int indent = 0;
|
||||
@@ -8743,7 +8743,7 @@ heredoc_identifier(struct parser_params *p)
|
||||
}
|
||||
|
||||
len = p->lex.pcur - (p->lex.pbeg + offset) - quote;
|
||||
if ((unsigned long)len >= HERETERM_LENGTH_MAX)
|
||||
if ((rb_ulen_t)len >= HERETERM_LENGTH_MAX)
|
||||
yyerror0("too long here document identifier");
|
||||
dispatch_scan_event(p, tHEREDOC_BEG);
|
||||
lex_goto_eol(p);
|
||||
|
||||
Reference in new issue
Block a user