@@ -11,7 +11,7 @@ public sealed class PyBuffer : IDisposable
1111 private PyObject _exporter ;
1212 private Py_buffer _view ;
1313
14- unsafe internal PyBuffer ( PyObject exporter , PyBUF flags )
14+ internal PyBuffer ( PyObject exporter , PyBUF flags )
1515 {
1616 _view = new Py_buffer ( ) ;
1717
@@ -25,17 +25,17 @@ unsafe internal PyBuffer(PyObject exporter, PyBUF flags)
2525 var intPtrBuf = new IntPtr [ _view . ndim ] ;
2626 if ( _view . shape != IntPtr . Zero )
2727 {
28- Marshal . Copy ( _view . shape , intPtrBuf , 0 , ( int ) _view . len * sizeof ( IntPtr ) ) ;
28+ Marshal . Copy ( _view . shape , intPtrBuf , 0 , _view . ndim ) ;
2929 Shape = intPtrBuf . Select ( x => ( long ) x ) . ToArray ( ) ;
3030 }
3131
3232 if ( _view . strides != IntPtr . Zero ) {
33- Marshal . Copy ( _view . strides , intPtrBuf , 0 , ( int ) _view . len * sizeof ( IntPtr ) ) ;
33+ Marshal . Copy ( _view . strides , intPtrBuf , 0 , _view . ndim ) ;
3434 Strides = intPtrBuf . Select ( x => ( long ) x ) . ToArray ( ) ;
3535 }
3636
3737 if ( _view . suboffsets != IntPtr . Zero ) {
38- Marshal . Copy ( _view . suboffsets , intPtrBuf , 0 , ( int ) _view . len * sizeof ( IntPtr ) ) ;
38+ Marshal . Copy ( _view . suboffsets , intPtrBuf , 0 , _view . ndim ) ;
3939 SubOffsets = intPtrBuf . Select ( x => ( long ) x ) . ToArray ( ) ;
4040 }
4141 }
0 commit comments