File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -928,41 +928,40 @@ _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
928928 }
929929
930930 b = PyByteArray_FromStringAndSize (NULL , n );
931- if (b == NULL )
931+ if (b == NULL ) {
932932 return NULL ;
933+ }
933934
934935 res = PyObject_CallMethodObjArgs (self , & _Py_ID (readinto ), b , NULL );
935936 if (res == NULL || res == Py_None ) {
936- Py_DECREF (b );
937- return res ;
937+ goto cleanup ;
938938 }
939939
940940 Py_ssize_t bytes_filled = PyNumber_AsSsize_t (res , PyExc_ValueError );
941- Py_DECREF (res );
941+ Py_CLEAR (res );
942942 if (bytes_filled == -1 && PyErr_Occurred ()) {
943- Py_DECREF (b );
944- return NULL ;
943+ goto cleanup ;
945944 }
946945 if (bytes_filled < 0 || bytes_filled > n ) {
947- Py_DECREF (b );
948946 PyErr_Format (PyExc_ValueError ,
949947 "readinto returned %zd outside buffer size %zd" ,
950948 bytes_filled , n );
951- return NULL ;
949+ goto cleanup ;
952950 }
953951
954952 res = PyObject_CallMethod (b , "resize" , "i" , bytes_filled );
955953 if (res != Py_None ) {
956- Py_DECREF (b );
957954 if (res != NULL ) {
958955 PyErr_Format (PyExc_ValueError ,
959956 "resize returned unexpected value %R" ,
960957 res );
961958 Py_CLEAR (res );
962959 }
963- return res ;
960+ goto cleanup ;
964961 }
965962 res = PyObject_CallMethod (b , "take_bytes" , NULL );
963+
964+ cleanup :
966965 Py_DECREF (b );
967966 return res ;
968967}
You can’t perform that action at this time.
0 commit comments