File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,23 @@ update_array_cache(ArrayGOObject *self)
4141 if (self -> list ) {
4242 if (self -> array ) {
4343 PyObject * container = PyTuple_Pack (2 , self -> array , self -> list );
44+ PyObject * new_array ;
4445 if (!container ) {
4546 return -1 ;
4647 }
47- Py_SETREF ( self -> array , PyArray_Concatenate (container , 0 ) );
48+ new_array = PyArray_Concatenate (container , 0 );
4849 Py_DECREF (container );
50+ if (!new_array ) {
51+ return -1 ;
52+ }
53+ Py_SETREF (self -> array , new_array );
4954 }
5055 else {
51- self -> array = PyArray_FROM_OT (self -> list , NPY_OBJECT );
56+ PyObject * new_array = PyArray_FROM_OT (self -> list , NPY_OBJECT );
57+ if (!new_array ) {
58+ return -1 ;
59+ }
60+ self -> array = new_array ;
5261 }
5362 PyArray_CLEARFLAGS ((PyArrayObject * )self -> array , NPY_ARRAY_WRITEABLE );
5463 Py_CLEAR (self -> list );
@@ -158,9 +167,20 @@ PyObject *
158167ArrayGO_copy (ArrayGOObject * self , PyObject * Py_UNUSED (unused ))
159168{
160169 ArrayGOObject * copy = PyObject_GC_New (ArrayGOObject , & ArrayGOType );
170+ if (!copy ) {
171+ return NULL ;
172+ }
161173 copy -> array = self -> array ;
162- copy -> list = self -> list ? PySequence_List (self -> list ) : NULL ;
163174 Py_XINCREF (copy -> array );
175+ if (self -> list ) {
176+ copy -> list = PySequence_List (self -> list );
177+ if (!copy -> list ) {
178+ Py_DECREF (copy );
179+ return NULL ;
180+ }
181+ } else {
182+ copy -> list = NULL ;
183+ }
164184 return (PyObject * )copy ;
165185}
166186
You can’t perform that action at this time.
0 commit comments