Skip to content

Commit

Permalink
Fix issue in jl_array_shrink where the offset wasn't correctly multip…
Browse files Browse the repository at this point in the history
…lied by a->elsize, so the array's data pointer got messed up.
  • Loading branch information
quinnj committed Jul 22, 2018
1 parent 545e1d3 commit f5d8f98
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,11 @@ STATIC_INLINE void jl_array_shrink(jl_array_t *a, size_t dec)
oldnbytes += a->maxsize;
}

char *originalptr = ((char*) a->data) - a->offset;
if (elsz == 1 && !isbitsunion) {
newbytes++;
oldnbytes++;
}
char *originalptr = ((char*) a->data) - a->offset * a->elsize;
if (a->flags.how == 1) {
//this is a julia-allocated buffer that needs to be marked
}
Expand All @@ -936,7 +940,7 @@ STATIC_INLINE void jl_array_shrink(jl_array_t *a, size_t dec)
}
size_t oldoffsnb = a->offset * elsz;
a->data = ((char*) jl_gc_managed_realloc(originalptr, newbytes, oldnbytes,
a->flags.isaligned, (jl_value_t*) a));
a->flags.isaligned, (jl_value_t*) a)) + oldoffsnb;
a->maxsize -= dec;
if (isbitsunion) {
newtypetagdata = jl_array_typetagdata(a);
Expand Down

0 comments on commit f5d8f98

Please sign in to comment.