File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1482,23 +1482,25 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
14821482 endoffile = (PyBytes_GET_SIZE (cres ) == 0 );
14831483
14841484 if (self -> pendingsize > 0 ) {
1485- PyObject * ctr ;
1486- char * ctrdata ;
1487-
14881485 if (PyBytes_GET_SIZE (cres ) > PY_SSIZE_T_MAX - self -> pendingsize ) {
14891486 PyErr_NoMemory ();
14901487 goto errorexit ;
14911488 }
14921489 rsize = PyBytes_GET_SIZE (cres ) + self -> pendingsize ;
1493- ctr = PyBytes_FromStringAndSize (NULL , rsize );
1494- if (ctr == NULL )
1490+
1491+ PyBytesWriter * writer = PyBytesWriter_Create (rsize );
1492+ if (writer == NULL ) {
14951493 goto errorexit ;
1496- ctrdata = PyBytes_AS_STRING (ctr );
1494+ }
1495+ char * ctrdata = PyBytesWriter_GetData (writer );
14971496 memcpy (ctrdata , self -> pending , self -> pendingsize );
14981497 memcpy (ctrdata + self -> pendingsize ,
14991498 PyBytes_AS_STRING (cres ),
15001499 PyBytes_GET_SIZE (cres ));
1501- Py_SETREF (cres , ctr );
1500+ Py_SETREF (cres , PyBytesWriter_Finish (writer ));
1501+ if (cres == NULL ) {
1502+ goto errorexit ;
1503+ }
15021504 self -> pendingsize = 0 ;
15031505 }
15041506
You can’t perform that action at this time.
0 commit comments