Skip to content

Commit

Permalink
Fix SEGV
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Apr 22, 2023
1 parent 63d5793 commit a903352
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
26 changes: 0 additions & 26 deletions node2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,6 @@ rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
n->node_id = -1;
}

typedef struct node_buffer_elem_struct {
struct node_buffer_elem_struct *next;
long len;
NODE buf[FLEX_ARY_LEN];
} node_buffer_elem_t;

typedef struct {
long idx, len;
node_buffer_elem_t *head;
node_buffer_elem_t *last;
} node_buffer_list_t;

struct node_buffer_struct {
node_buffer_list_t unmarkable;
node_buffer_list_t markable;
struct rb_ast_local_table_link *local_tables;
VALUE mark_hash;
// - id (sequence number)
// - token_type
// - text of token
// - location info
// Array, whose entry is array
VALUE tokens;
rb_parser_config_t *config;
};

#define ruby_xmalloc ast->node_buffer->config->malloc
#define rb_ident_hash_new ast->node_buffer->config->ident_hash_new
#define rb_xmalloc_mul_add ast->node_buffer->config->xmalloc_mul_add
Expand Down
28 changes: 27 additions & 1 deletion node2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@

typedef void (*bug_report_func)(const char *fmt, ...);

typedef struct node_buffer_elem_struct {
struct node_buffer_elem_struct *next;
long len;
NODE buf[FLEX_ARY_LEN];
} node_buffer_elem_t;

typedef struct {
long idx, len;
node_buffer_elem_t *head;
node_buffer_elem_t *last;
} node_buffer_list_t;

struct node_buffer_struct {
node_buffer_list_t unmarkable;
node_buffer_list_t markable;
struct rb_ast_local_table_link *local_tables;
VALUE mark_hash;
// - id (sequence number)
// - token_type
// - text of token
// - location info
// Array, whose entry is array
VALUE tokens;
rb_parser_config_t *config;
};

RUBY_SYMBOL_EXPORT_BEGIN

rb_ast_t *rb_ast_new(rb_parser_config_t *config);
Expand Down Expand Up @@ -73,7 +99,7 @@ static inline VALUE
rb_node_set_type(rb_ast_t *ast, NODE *n, enum node_type t)
{
#if RUBY_DEBUG
rb_ast_node_type_change(n, t);
rb_ast_node_type_change(n, t, ast->node_buffer->config->bug);
#endif
return nd_init_type(n, t);
}
Expand Down

0 comments on commit a903352

Please sign in to comment.