diff options
author | S-H-GAMELINKS <[email protected]> | 2024-03-20 00:26:54 +0900 |
---|---|---|
committer | Yuichiro Kaneko <[email protected]> | 2024-03-21 18:10:02 +0900 |
commit | 060a71d4e75e3329b5cae7cd416addba7c5bd263 (patch) | |
tree | 69fea6ebee9353543133425c84f9bac84ac93004 /internal/ruby_parser.h | |
parent | 9e3077a7a6a59512aea5538adf173a33bbc5db3f (diff) |
Fix Ripper memory allocation size when enabled Universal Parser
The size of `struct parser_params` is 8 bytes difference in `ripper_s_allocate` and `rb_ruby_parser_allocate` when the universal parser is
enabled.
This causes a situation where `*r->p` is not fully initialized in `ripper_s_allocate` as shown below.
```console
(gdb) p *r->p
$2 = {heap = 0x0, lval = 0x0, yylloc = 0x0, lex = {strterm = 0x0, gets = 0x0, input = 0, string_buffer = {head = 0x0, last = 0x0}, lastlin
e = 0x0,
nextline = 0x0, pbeg = 0x0, pcur = 0x0, pend = 0x0, ptok = 0x0, gets_ = {ptr = 0, call = 0x0}, state = EXPR_NONE, paren_nest = 0, lpar
_seen = 0,
debug = 0, has_shebang = 0, token_seen = 0, token_info_enabled = 0, error_p = 0, cr_seen = 0, value = 0, result = 0, parsing_thread = 0, s_value = 0,
s_lvalue = 0, s_value_stack = 2097}
````
This seems to cause `double free or corruption (!prev)` and SEGV.
So, fixing this by introduce `rb_ripper_parser_params_allocate` and `rb_ruby_parser_config` functions for Ripper, and `struct parser_params` same size is returned.
Diffstat (limited to 'internal/ruby_parser.h')
-rw-r--r-- | internal/ruby_parser.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h index 7b4c715268..1c59851f0d 100644 --- a/internal/ruby_parser.h +++ b/internal/ruby_parser.h @@ -12,6 +12,7 @@ RUBY_SYMBOL_EXPORT_BEGIN #ifdef UNIVERSAL_PARSER +const rb_parser_config_t *rb_ruby_parser_config(void); rb_parser_t *rb_parser_params_allocate(void); rb_parser_t *rb_parser_params_new(void); #endif |