Commit 6a0ae8ec authored by Robert Bradshaw's avatar Robert Bradshaw

Merge branch 'master' into 0.25.x

parents 4bf8b9b2 176ed5e4
...@@ -950,8 +950,11 @@ static void __Pyx_Coroutine_del(PyObject *self) { ...@@ -950,8 +950,11 @@ static void __Pyx_Coroutine_del(PyObject *self) {
static PyObject * static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self) __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
{ {
Py_INCREF(self->gi_name); PyObject *name = self->gi_name;
return self->gi_name; // avoid NULL pointer dereference during garbage collection
if (unlikely(!name)) name = Py_None;
Py_INCREF(name);
return name;
} }
static int static int
...@@ -978,8 +981,11 @@ __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value) ...@@ -978,8 +981,11 @@ __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
static PyObject * static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self) __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
{ {
Py_INCREF(self->gi_qualname); PyObject *name = self->gi_qualname;
return self->gi_qualname; // avoid NULL pointer dereference during garbage collection
if (unlikely(!name)) name = Py_None;
Py_INCREF(name);
return name;
} }
static int static int
......
...@@ -121,12 +121,12 @@ static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) { ...@@ -121,12 +121,12 @@ static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
void *items = (void*) self->data.ob_item; void *items = (void*) self->data.ob_item;
Py_ssize_t newsize; Py_ssize_t newsize;
if (n < self->ob_size) { if (n < self->allocated && n*4 > self->allocated) {
self->ob_size = n; self->ob_size = n;
return 0; return 0;
} }
newsize = n + (n / 2) + 1; newsize = n + (n / 2) + 1;
if (newsize <= self->allocated) { /* overflow */ if (newsize <= n) { /* overflow */
PyErr_NoMemory(); PyErr_NoMemory();
return -1; return -1;
} }
...@@ -134,7 +134,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { ...@@ -134,7 +134,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
if (items == NULL) { if (items == NULL) {
PyErr_NoMemory(); PyErr_NoMemory();
return -1; return -1;
} }
self->data.ob_item = (char*) items; self->data.ob_item = (char*) items;
self->ob_size = n; self->ob_size = n;
self->allocated = newsize; self->allocated = newsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment