@@ -490,16 +490,18 @@ static PyObject *
490490unicode_aswidecharstring (PyObject * self , PyObject * args )
491491{
492492 PyObject * unicode , * result ;
493- Py_ssize_t size = 100 ;
493+ Py_ssize_t size = UNINITIALIZED_SIZE ;
494494 wchar_t * buffer ;
495495
496496 if (!PyArg_ParseTuple (args , "O" , & unicode ))
497497 return NULL ;
498498
499499 NULLABLE (unicode );
500500 buffer = PyUnicode_AsWideCharString (unicode , & size );
501- if (buffer == NULL )
501+ if (buffer == NULL ) {
502+ assert (size == UNINITIALIZED_SIZE );
502503 return NULL ;
504+ }
503505
504506 result = PyUnicode_FromWideChar (buffer , size + 1 );
505507 PyMem_Free (buffer );
@@ -624,15 +626,17 @@ unicode_asutf8andsize(PyObject *self, PyObject *args)
624626 PyObject * unicode ;
625627 Py_ssize_t buflen ;
626628 const char * s ;
627- Py_ssize_t size = -100 ;
629+ Py_ssize_t size = UNINITIALIZED_SIZE ;
628630
629631 if (!PyArg_ParseTuple (args , "On" , & unicode , & buflen ))
630632 return NULL ;
631633
632634 NULLABLE (unicode );
633635 s = PyUnicode_AsUTF8AndSize (unicode , & size );
634- if (s == NULL )
636+ if (s == NULL ) {
637+ assert (size == UNINITIALIZED_SIZE );
635638 return NULL ;
639+ }
636640
637641 return Py_BuildValue ("(y#n)" , s , buflen , size );
638642}
@@ -726,14 +730,15 @@ unicode_decodeutf7stateful(PyObject *self, PyObject *args)
726730 const char * data ;
727731 Py_ssize_t size ;
728732 const char * errors = NULL ;
729- Py_ssize_t consumed ;
733+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
730734 PyObject * result ;
731735
732736 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
733737 return NULL ;
734738
735739 result = PyUnicode_DecodeUTF7Stateful (data , size , errors , & consumed );
736740 if (!result ) {
741+ assert (consumed == UNINITIALIZED_SIZE );
737742 return NULL ;
738743 }
739744 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -760,14 +765,15 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
760765 const char * data ;
761766 Py_ssize_t size ;
762767 const char * errors = NULL ;
763- Py_ssize_t consumed = 123456789 ;
768+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
764769 PyObject * result ;
765770
766771 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
767772 return NULL ;
768773
769774 result = PyUnicode_DecodeUTF8Stateful (data , size , errors , & consumed );
770775 if (!result ) {
776+ assert (consumed == UNINITIALIZED_SIZE );
771777 return NULL ;
772778 }
773779 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -788,7 +794,7 @@ unicode_decodeutf32(PyObject *self, PyObject *args)
788794 const char * data ;
789795 Py_ssize_t size ;
790796 const char * errors = NULL ;
791- int byteorder ;
797+ int byteorder = UNINITIALIZED_INT ;
792798 PyObject * result ;
793799
794800 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -808,15 +814,16 @@ unicode_decodeutf32stateful(PyObject *self, PyObject *args)
808814 const char * data ;
809815 Py_ssize_t size ;
810816 const char * errors = NULL ;
811- int byteorder ;
812- Py_ssize_t consumed ;
817+ int byteorder = UNINITIALIZED_INT ;
818+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
813819 PyObject * result ;
814820
815821 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
816822 return NULL ;
817823
818824 result = PyUnicode_DecodeUTF32Stateful (data , size , errors , & byteorder , & consumed );
819825 if (!result ) {
826+ assert (consumed == UNINITIALIZED_SIZE );
820827 return NULL ;
821828 }
822829 return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -837,7 +844,7 @@ unicode_decodeutf16(PyObject *self, PyObject *args)
837844 const char * data ;
838845 Py_ssize_t size ;
839846 const char * errors = NULL ;
840- int byteorder = 0 ;
847
2F18
+ int byteorder = UNINITIALIZED_INT ;
841848 PyObject * result ;
842849
843850 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -857,15 +864,16 @@ unicode_decodeutf16stateful(PyObject *self, PyObject *args)
857864 const char * data ;
858865 Py_ssize_t size ;
859866 const char * errors = NULL ;
860- int byteorder ;
861- Py_ssize_t consumed ;
867+ int byteorder = UNINITIALIZED_INT ;
868+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
862869 PyObject * result ;
863870
864871 if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
865872 return NULL ;
866873
867874 result = PyUnicode_DecodeUTF16Stateful (data , size , errors , & byteorder , & consumed );
868875 if (!result ) {
876+ assert (consumed == UNINITIALIZED_SIZE );
869877 return NULL ;
870878 }
871879 return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -1019,14 +1027,15 @@ unicode_decodembcsstateful(PyObject *self, PyObject *args)
10191027 const char * data ;
10201028 Py_ssize_t size ;
10211029 const char * errors = NULL ;
1022- Py_ssize_t consumed ;
1030+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
10231031 PyObject * result ;
10241032
10251033 if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
10261034 return NULL ;
10271035
10281036 result = PyUnicode_DecodeMBCSStateful (data , size , errors , & consumed );
10291037 if (!result ) {
1038+ assert (consumed == UNINITIALIZED_SIZE );
10301039 return NULL ;
10311040 }
10321041 return Py_BuildValue ("(Nn)" , result , consumed );
@@ -1040,14 +1049,15 @@ unicode_decodecodepagestateful(PyObject *self, PyObject *args)
10401049 const char * data ;
10411050 Py_ssize_t size ;
10421051 const char * errors = NULL ;
1043- Py_ssize_t consumed ;
1052+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
10441053 PyObject * result ;
10451054
10461055 if (!PyArg_ParseTuple (args , "iy#|z" , & code_page , & data , & size , & errors ))
10471056 return NULL ;
10481057
10491058 result = PyUnicode_DecodeCodePageStateful (code_page , data , size , errors , & consumed );
10501059 if (!result ) {
1060+ assert (consumed == UNINITIALIZED_SIZE );
10511061 return NULL ;
10521062 }
10531063 return
DCA8
Py_BuildValue ("(Nn)" , result , consumed );
0 commit comments