@@ -491,16 +491,18 @@ static PyObject *
491491unicode_aswidecharstring (PyObject * self , PyObject * args )
492492{
493493 PyObject * unicode , * result ;
494- Py_ssize_t size = 100 ;
494+ Py_ssize_t size = UNINITIALIZED_SIZE ;
495495 wchar_t * buffer ;
496496
497497 if (!PyArg_ParseTuple (args , "O" , & unicode ))
498498 return NULL ;
499499
500500 NULLABLE (unicode );
501501 buffer = PyUnicode_AsWideCharString (unicode , & size );
502- if (buffer == NULL )
502+ if (buffer == NULL ) {
503+ assert (size == UNINITIALIZED_SIZE );
503504 return NULL ;
505+ }
504506
505507 result = PyUnicode_FromWideChar (buffer , size + 1 );
506508 PyMem_Free (buffer );
@@ -625,15 +627,17 @@ unicode_asutf8andsize(PyObject *self, PyObject *args)
625627 PyObject * unicode ;
626628 Py_ssize_t buflen ;
627629 const char * s ;
628- Py_ssize_t size = -100 ;
630+ Py_ssize_t size = UNINITIALIZED_SIZE ;
629631
630632 if (!PyArg_ParseTuple (args , "On" , & unicode , & buflen ))
631633 return NULL ;
632634
633635 NULLABLE (unicode );
634636 s = PyUnicode_AsUTF8AndSize (unicode , & size );
635- if (s == NULL )
637+ if (s == NULL ) {
638+ assert (size == UNINITIALIZED_SIZE );
636639 return NULL ;
640+ }
637641
638642 return Py_BuildValue ("(y#n)" , s , buflen , size );
639643}
@@ -735,14 +739,15 @@ unicode_decodeutf7stateful(PyObject *self, PyObject *args)
735739 const char * data ;
736740 Py_ssize_t size ;
737741 const char * errors = NULL ;
738- Py_ssize_t consumed ;
742+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
739743 PyObject * result ;
740744
741745 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
742746 return NULL ;
743747
744748 result = PyUnicode_DecodeUTF7Stateful (data , size , errors , & consumed );
745749 if (!result ) {
750+ assert (consumed == UNINITIALIZED_SIZE );
746751 return NULL ;
747752 }
748753 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -769,14 +774,15 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
769774 const char * data ;
770775 Py_ssize_t size ;
771776 const char * errors = NULL ;
772- Py_ssize_t consumed = 123456789 ;
777+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
773778 PyObject * result ;
774779
775780 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
776781 return NULL ;
777782
778783 result = PyUnicode_DecodeUTF8Stateful (data , size , errors , & consumed );
779784 if (!result ) {
785+ assert (consumed == UNINITIALIZED_SIZE );
780786 return NULL ;
781787 }
782788 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -797,7 +803,7 @@ unicode_decodeutf32(PyObject *self, PyObject *args)
797803 const char * data ;
798804 Py_ssize_t size ;
799805 const char * errors = NULL ;
800- int byteorder ;
806+ int byteorder = UNINITIALIZED_INT ;
801807 PyObject * result ;
802808
803809 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -817,15 +823,16 @@ unicode_decodeutf32stateful(PyObject *self, PyObject *args)
817823 const char * data ;
818824 Py_ssize_t size ;
819825 const char * errors = NULL ;
820- int byteorder ;
821- Py_ssize_t consumed ;
826+ int byteorder = UNINITIALIZED_INT ;
827+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
822828 PyObject * result ;
823829
824830 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
825831 return NULL ;
826832
827833 result = PyUnicode_DecodeUTF32Stateful (data , size , errors , & byteorder , & consumed );
828834 if (!result ) {
835+ assert (consumed == UNINITIALIZED_SIZE );
829836 return NULL ;
830837 }
831838 return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -846,7 +853,7 @@ unicode_decodeutf16(PyObject *self, PyObject *args)
846853 const char * data ;
847854 Py_ssize_t size ;
848855 const char * errors = NULL ;
849- int byteorder = 0 ;
856+ int byteorder = UNINITIALIZED_INT ;
850857 PyObject * result ;
851858
852859 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -866,15 +873,16 @@ unicode_decodeutf16stateful(PyObject *self, PyObject *args)
866873 const char * data ;
867874 Py_ssize_t size ;
868875 const char * errors = NULL ;
869- int byteorder ;
870- Py_ssize_t consumed ;
876+ int byteorder = UNINITIALIZED_INT ;
877+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
871878 PyObject * result ;
872879
873880 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
874881 return NULL ;
875882
876883 result = PyUnicode_DecodeUTF16Stateful (data , size , errors , & byteorder , & consumed );
877884 if (!result ) {
885+ assert (consumed == UNINITIALIZED_SIZE );
878886 return NULL ;
879887 }
880888 return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -1028,14 +1036,15 @@ unicode_decodembcsstateful(PyObject *self, PyObject *args)
10281036 const char * data ;
10291037 Py_ssize_t size ;
10301038 const char * errors = NULL ;
1031- Py_ssize_t consumed ;
1039+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
10321040 PyObject * result ;
10331041
10341042 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
10351043 return NULL ;
10361044
10371045 result = PyUnicode_DecodeMBCSStateful (data , size , errors , & consumed );
10381046 if (!result ) {
1047+ assert (consumed == UNINITIALIZED_SIZE );
10391048 return NULL ;
10401049 }
10411050 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -1049,14 +1058,15 @@ unicode_decodecodepagestateful(PyObject *self, PyObject *args)
10491058 const char * data ;
10501059 Py_ssize_t size ;
10511060 const char * errors = NULL ;
1052- Py_ssize_t consumed ;
1061+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
10531062 PyObject * result ;
10541063
10551064 if (!PyArg_ParseTuple (args , "iy#|z" , & code_page , & data , & size , & errors ))
10561065 return NULL ;
10571066
10581067 result = PyUnicode_DecodeCodePageStateful (code_page , data , size , errors , & consumed );
10591068 if (!result ) {
1069+ assert (consumed == UNINITIALIZED_SIZE );
10601070 return NULL ;
10611071 }
10621072 return Py_BuildValue ("(Nn)" , result , consumed );
0 commit comments