Skip to content

Commit

Permalink
Fix pointer arithmetic in inlined CArrays in CStruct/CPPStruct REPRs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiepi committed Jul 12, 2019
1 parent 729303d commit 6738408
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/nativecall.c
Expand Up @@ -1011,15 +1011,15 @@ void MVM_nativecall_refresh(MVMThreadContext *tc, MVMObject *cthingy) {
MVMint64 i;

for (i = 0; i < repr_data->num_attributes; i++) {
MVMint32 kind = repr_data->attribute_locations[i] & MVM_CSTRUCT_ATTR_MASK;
MVMint32 slot = repr_data->attribute_locations[i] >> MVM_CSTRUCT_ATTR_SHIFT;
void **cptr = NULL; /* Address of the struct member holding the pointer in the C storage. */
MVMint32 kind = repr_data->attribute_locations[i] & MVM_CSTRUCT_ATTR_MASK;
MVMint32 slot = repr_data->attribute_locations[i] >> MVM_CSTRUCT_ATTR_SHIFT;
void *cptr = NULL; /* Address of the struct member holding the pointer in the C storage. */
void *objptr = NULL; /* The pointer in the object representing the C object. */

if (kind == MVM_CSTRUCT_ATTR_IN_STRUCT || !body->child_objs[slot])
continue;

cptr = (void**)((uintptr_t)storage + (uintptr_t)repr_data->struct_offsets[i]);
cptr = (void *)(storage + (uintptr_t)repr_data->struct_offsets[i]);
if (IS_CONCRETE(body->child_objs[slot])) {
switch (kind) {
case MVM_CSTRUCT_ATTR_CARRAY:
Expand Down Expand Up @@ -1050,7 +1050,7 @@ void MVM_nativecall_refresh(MVMThreadContext *tc, MVMObject *cthingy) {
objptr = NULL;
}

if (objptr != *cptr)
if (objptr != cptr)
body->child_objs[slot] = NULL;
else
MVM_nativecall_refresh(tc, body->child_objs[slot]);
Expand All @@ -1071,7 +1071,7 @@ void MVM_nativecall_refresh(MVMThreadContext *tc, MVMObject *cthingy) {
if (kind == MVM_CPPSTRUCT_ATTR_IN_STRUCT || !body->child_objs[slot])
continue;

cptr = (void*)((uintptr_t)storage + (uintptr_t)repr_data->struct_offsets[i]);
cptr = (void *)(storage + (uintptr_t)repr_data->struct_offsets[i]);
if (IS_CONCRETE(body->child_objs[slot])) {
switch (kind) {
case MVM_CPPSTRUCT_ATTR_CARRAY:
Expand Down

0 comments on commit 6738408

Please sign in to comment.