diff options
| author | Jean byroot Boussier <jean.boussier+github@shopify.com> | 2024-08-06 19:34:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-06 10:34:39 -0700 |
| commit | 65cca99b30c65d462aa67969e0f16f6e45db4705 (patch) | |
| tree | abe5a234af639d5a066c6a07f3db7929e59051df /parse.y | |
| parent | f85c7deacc25738bd83ba182370c283ba82b61d4 (diff) | |
parse.y: const_decl_path don't replace destination node by a literal (#11314)
[Bug #20668]
The `dest` node is assumed to be a `CDECL`, so overwriting it with
a `LIT` cause a crash on the next iteration.
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -13528,9 +13528,9 @@ mark_lvar_used(struct parser_params *p, NODE *rhs) } static NODE * -const_decl_path(struct parser_params *p, NODE **dest) +const_decl_path(struct parser_params *p, NODE *dest) { - NODE *n = *dest; + NODE *n = dest; if (!nd_type_p(n, NODE_CALL)) { const YYLTYPE *loc = &n->nd_loc; VALUE path; @@ -13558,7 +13558,7 @@ const_decl_path(struct parser_params *p, NODE **dest) path = rb_ary_join(rb_ary_reverse(path), rb_str_new_cstr("::")); path = rb_fstring(path); } - *dest = n = NEW_LIT(path, loc); + n = NEW_LIT(path, loc); RB_OBJ_WRITTEN(p->ast, Qnil, RNODE_LIT(n)->nd_lit); } return n; @@ -13584,7 +13584,7 @@ ensure_shareable_node(struct parser_params *p, NODE **dest, NODE *value, const Y { NODE *fcore = NEW_LIT(rb_mRubyVMFrozenCore, loc); NODE *args = NEW_LIST(value, loc); - args = list_append(p, args, const_decl_path(p, dest)); + args = list_append(p, args, const_decl_path(p, *dest)); return NEW_CALL(fcore, rb_intern("ensure_shareable"), args, loc); } |
