зеркало из https://github.com/github/ruby.git
node.c: Fix possible alignment bugs
* node.c (rb_node_buffer_new): Use offsetof for node_buffer_t size calculation. * node.c (rb_ast_newnode): Use offsetof for node_buffer_elem_t size calculation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
77fae4b4c0
Коммит
f7fb086789
4
node.c
4
node.c
|
@ -1235,7 +1235,7 @@ struct node_buffer_struct {
|
|||
node_buffer_t *
|
||||
rb_node_buffer_new()
|
||||
{
|
||||
node_buffer_t *nb = xmalloc(sizeof(node_buffer_t) + 16 * sizeof(NODE));
|
||||
node_buffer_t *nb = xmalloc(offsetof(node_buffer_t, body) + offsetof(node_buffer_elem_t, buf) + 16 * sizeof(NODE));
|
||||
nb->idx = 0;
|
||||
nb->len = 16;
|
||||
nb->head = &nb->body;
|
||||
|
@ -1263,7 +1263,7 @@ rb_ast_newnode(rb_ast_t *ast)
|
|||
if (nb->idx >= nb->len) {
|
||||
long n = nb->len * 2;
|
||||
node_buffer_elem_t *nbe;
|
||||
nbe = xmalloc(sizeof(node_buffer_elem_t) + n * sizeof(NODE));
|
||||
nbe = xmalloc(offsetof(node_buffer_elem_t, buf) + n * sizeof(NODE));
|
||||
nb->idx = 0;
|
||||
nb->len = n;
|
||||
nbe->next = nb->head;
|
||||
|
|
Загрузка…
Ссылка в новой задаче