@@ -149,6 +149,9 @@ static TypeContext *createTypeContext(void) {
149149 TypeContext * pc ;
150150
151151 pc = PyObject_Malloc (sizeof (TypeContext ));
152+ if (pc == NULL ) {
153+ return NULL ;
154+ }
152155 if (!pc ) {
153156 PyErr_NoMemory ();
154157 return NULL ;
@@ -183,11 +186,17 @@ static PyObject *get_values(PyObject *obj) {
183186 // without going through and object array of Timestamps.
184187 if (PyObject_HasAttrString (obj , "tz" )) {
185188 PyObject * tz = PyObject_GetAttrString (obj , "tz" );
189+ if (tz == NULL ) {
190+ return NULL ;
191+ }
186192 if (tz != Py_None ) {
187193 // Go through object array if we have dt64tz, since tz info will
188194 // be lost if values is used directly.
189195 Py_DECREF (tz );
190196 values = PyObject_CallMethod (obj , "__array__" , NULL );
197+ if (values == NULL ) {
198+ return NULL ;
199+ }
191200 return values ;
192201 }
193202 Py_DECREF (tz );
@@ -211,10 +220,19 @@ static PyObject *get_values(PyObject *obj) {
211220
212221 if (values == NULL ) {
213222 PyObject * typeRepr = PyObject_Repr ((PyObject * )Py_TYPE (obj ));
223+ if (typeRepr == NULL ) {
224+ return NULL ;
225+ }
214226 PyObject * repr ;
215227 if (PyObject_HasAttrString (obj , "dtype" )) {
216228 PyObject * dtype = PyObject_GetAttrString (obj , "dtype" );
229+ if (dtype == NULL ) {
230+ return NULL ;
231+ }
217232 repr = PyObject_Repr (dtype );
233+ if (repr == NULL ) {
234+ return NULL ;
235+ }
218236 Py_DECREF (dtype );
219237 } else {
220238 repr = PyUnicode_FromString ("<unknown dtype>" );
@@ -233,12 +251,18 @@ static PyObject *get_values(PyObject *obj) {
233251
234252static PyObject * get_sub_attr (PyObject * obj , char * attr , char * subAttr ) {
235253 PyObject * tmp = PyObject_GetAttrString (obj , attr );
254+ if (tmp == NULL ) {
255+ return NULL ;
256+ }
236257 PyObject * ret ;
237258
238259 if (tmp == 0 ) {
239260 return 0 ;
240261 }
241262 ret = PyObject_GetAttrString (tmp , subAttr );
263+ if (ret == NULL ) {
264+ return ret ;
265+ }
242266 Py_DECREF (tmp );
243267
244268 return ret ;
0 commit comments