From 50a50441a148a9ea3fbc1629e065d88a4f28a419 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Tue, 8 Aug 2006 05:13:02 +0000 Subject: Fix segfault in Ticket #238 --- numpy/core/src/arraymethods.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'numpy/core/src/arraymethods.c') diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index e13061a4e..cc885b90f 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -359,6 +359,12 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace) copyswapn = self->descr->f->copyswapn; if (inplace) { + if (!PyArray_ISWRITEABLE(self)) { + PyErr_SetString(PyExc_RuntimeError, + "Cannot byte-swap in-place on a " \ + "read-only array"); + return NULL; + } size = PyArray_SIZE(self); if (PyArray_ISONESEGMENT(self)) { copyswapn(self->data, self->descr->elsize, NULL, -1, size, 1, self); -- cgit v1.2.1