Skip to content

Commit

Permalink
Fix possible access to fromspace in MVM_repr_dimensions
Browse files Browse the repository at this point in the history
Allocating the result array can cause GC which may move obj, so move the
allocation after the call to the repr function. We don't need it that early
anyway.
  • Loading branch information
niner committed Jul 27, 2019
1 parent 07f6305 commit ca9d44f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/6model/reprconv.c
Expand Up @@ -585,9 +585,10 @@ MVMObject * MVM_repr_dimensions(MVMThreadContext *tc, MVMObject *obj) {
if (IS_CONCRETE(obj)) {
MVMint64 num_dims, i;
MVMint64 *dims;
MVMObject *result = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIntArray);
MVMObject *result;
REPR(obj)->pos_funcs.dimensions(tc, STABLE(obj), obj, OBJECT_BODY(obj),
&num_dims, &dims);
result = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIntArray);
for (i = 0; i < num_dims; i++)
MVM_repr_bind_pos_i(tc, result, i, dims[i]);
return result;
Expand Down

0 comments on commit ca9d44f

Please sign in to comment.