Skip to content

Commit

Permalink
error to upd_data if datasv set to different size from nbytes
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jan 6, 2025
1 parent c926b56 commit 5f6c93b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- add Pars type-spec "!real" which makes it an error to supply real values (#511)
- now an error to call Ops::carg on a real value, or Ops::czip on complex inputs (#511)
- fix packsize for indx to base on ptrsize, not ivsize (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1092246) - thanks Helge Deller for report
- now an error to upd_data if datasv set to different size from nbytes

2.098 2025-01-03
- fix Windows build problems
Expand Down
3 changes: 3 additions & 0 deletions lib/PDL/Core.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,9 @@ upd_data(self, keep_datasv=0)
self->data = SvPV_nolen((SV*)self->datasv);
} else if (self->datasv) {
PDLDEBUG_f(printf("upd_data zap datasv\n"));
Size_t svsize = SvCUR((SV*)self->datasv);
if (svsize != self->nbytes)
croak("Trying to upd_data but datasv now length %zu instead of %td", svsize, self->nbytes);
memmove(self->data, SvPV_nolen((SV*)self->datasv), self->nbytes);
SvREFCNT_dec(self->datasv);
self->datasv = NULL;
Expand Down

0 comments on commit 5f6c93b

Please sign in to comment.