diff options
author | Armin Rigo <arigo@tunes.org> | 2014-06-16 15:41:21 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2014-06-16 15:41:21 +0200 |
commit | 72e60a15d3638f90bb13810533e991a2f0ca656d (patch) | |
tree | 47aa2176fa38026f4acaf55d749ffb1f97074751 | |
parent | e8d953e4014f553bba9f7fecd046c2e7545dfd30 (diff) | |
download | cffi-72e60a15d3638f90bb13810533e991a2f0ca656d.tar.gz |
Force the "strides" to be non-NULL. With a NULL strides, CPython >= 3.3
seems to segfault when doing "mymemoryview[:5] = ffi.buffer(..)". I
have no clue how we're supposed to use this messy interface.
-rw-r--r-- | c/minibuffer.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/c/minibuffer.h b/c/minibuffer.h index 289dc4a..6d3eae5 100644 --- a/c/minibuffer.h +++ b/c/minibuffer.h @@ -105,8 +105,12 @@ static PyObject *mb_str(MiniBufferObj *self) static int mb_getbuf(MiniBufferObj *self, Py_buffer *view, int flags) { - return PyBuffer_FillInfo(view, NULL, self->mb_data, self->mb_size, - /*readonly=*/0, PyBUF_CONTIG | PyBUF_FORMAT); + static Py_ssize_t dummy_stride = 1; + int res = PyBuffer_FillInfo(view, (PyObject *)self, + self->mb_data, self->mb_size, + /*readonly=*/0, PyBUF_CONTIG | PyBUF_FORMAT); + view->strides = &dummy_stride; + return res; } static PySequenceMethods mb_as_sequence = { |