@@ -491,16 +491,18 @@ static PyObject *
491
491
unicode_aswidecharstring (PyObject * self , PyObject * args )
492
492
{
493
493
PyObject * unicode , * result ;
494
- Py_ssize_t size = 100 ;
494
+ Py_ssize_t size = UNINITIALIZED_SIZE ;
495
495
wchar_t * buffer ;
496
496
497
497
if (!PyArg_ParseTuple (args , "O" , & unicode ))
498
498
return NULL ;
499
499
500
500
NULLABLE (unicode );
501
501
buffer = PyUnicode_AsWideCharString (unicode , & size );
502
- if (buffer == NULL )
502
+ if (buffer == NULL ) {
503
+ assert (size == UNINITIALIZED_SIZE );
503
504
return NULL ;
505
+ }
504
506
505
507
result = PyUnicode_FromWideChar (buffer , size + 1 );
506
508
PyMem_Free (buffer );
@@ -625,15 +627,17 @@ unicode_asutf8andsize(PyObject *self, PyObject *args)
625
627
PyObject * unicode ;
626
628
Py_ssize_t buflen ;
627
629
const char * s ;
628
- Py_ssize_t size = -100 ;
630
+ Py_ssize_t size = UNINITIALIZED_SIZE ;
629
631
630
632
if (!PyArg_ParseTuple (args , "On" , & unicode , & buflen ))
631
633
return NULL ;
632
634
633
635
NULLABLE (unicode );
634
636
s = PyUnicode_AsUTF8AndSize (unicode , & size );
635
- if (s == NULL )
637
+ if (s == NULL ) {
638
+ assert (size == UNINITIALIZED_SIZE );
636
639
return NULL ;
640
+ }
637
641
638
642
return Py_BuildValue ("(y#n)" , s , buflen , size );
639
643
}
@@ -735,14 +739,15 @@ unicode_decodeutf7stateful(PyObject *self, PyObject *args)
735
739
const char * data ;
736
740
Py_ssize_t size ;
737
741
const char * errors = NULL ;
738
- Py_ssize_t consumed ;
742
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
739
743
PyObject * result ;
740
744
741
745
if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
742
746
return NULL ;
743
747
744
748
result = PyUnicode_DecodeUTF7Stateful (data , size , errors , & consumed );
745
749
if (!result ) {
750
+ assert (consumed == UNINITIALIZED_SIZE );
746
751
return NULL ;
747
752
}
748
753
return Py_BuildValue ("(Nn)" , result , consumed );
@@ -769,14 +774,15 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
769
774
const char * data ;
770
775
Py_ssize_t size ;
771
776
const char * errors = NULL ;
772
- Py_ssize_t consumed = 123456789 ;
777
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
773
778
PyObject * result ;
774
779
775
780
if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
776
781
return NULL ;
777
782
778
783
result = PyUnicode_DecodeUTF8Stateful (data , size , errors , & consumed );
779
784
if (!result ) {
785
+ assert (consumed == UNINITIALIZED_SIZE );
780
786
return NULL ;
781
787
}
782
788
return Py_BuildValue ("(Nn)" , result , consumed );
@@ -797,7 +803,7 @@ unicode_decodeutf32(PyObject *self, PyObject *args)
797
803
const char * data ;
798
804
Py_ssize_t size ;
799
805
const char * errors = NULL ;
800
- int byteorder ;
806
+ int byteorder = UNINITIALIZED_INT ;
801
807
PyObject * result ;
802
808
803
809
if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -817,15 +823,16 @@ unicode_decodeutf32stateful(PyObject *self, PyObject *args)
817
823
const char * data ;
818
824
Py_ssize_t size ;
819
825
const char * errors = NULL ;
820
- int byteorder ;
821
- Py_ssize_t consumed ;
826
+ int byteorder = UNINITIALIZED_INT ;
827
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
822
828
PyObject * result ;
823
829
824
830
if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
825
831
return NULL ;
826
832
827
833
result = PyUnicode_DecodeUTF32Stateful (data , size , errors , & byteorder , & consumed );
828
834
if (!result ) {
835
+ assert (consumed == UNINITIALIZED_SIZE );
829
836
return NULL ;
830
837
}
831
838
return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -846,7 +853,7 @@ unicode_decodeutf16(PyObject *self, PyObject *args)
846
853
const char * data ;
847
854
Py_ssize_t size ;
848
855
const char * errors = NULL ;
849
- int byteorder = 0 ;
856
+ int byteorder = UNINITIALIZED_INT ;
850
857
PyObject * result ;
851
858
852
859
if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
@@ -866,15 +873,16 @@ unicode_decodeutf16stateful(PyObject *self, PyObject *args)
866
873
const char * data ;
867
874
Py_ssize_t size ;
868
875
const char * errors = NULL ;
869
- int byteorder ;
870
- Py_ssize_t consumed ;
876
+ int byteorder = UNINITIALIZED_INT ;
877
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
871
878
PyObject * result ;
872
879
873
880
if (!PyArg_ParseTuple (args , "iy#|z" , & byteorder , & data , & size , & errors ))
874
881
return NULL ;
875
882
876
883
result = PyUnicode_DecodeUTF16Stateful (data , size , errors , & byteorder , & consumed );
877
884
if (!result ) {
885
+ assert (consumed == UNINITIALIZED_SIZE );
878
886
return NULL ;
879
887
}
880
888
return Py_BuildValue ("(iNn)" , byteorder , result , consumed );
@@ -1028,14 +1036,15 @@ unicode_decodembcsstateful(PyObject *self, PyObject *args)
1028
1036
const char * data ;
1029
1037
Py_ssize_t size ;
1030
1038
const char * errors = NULL ;
1031
- Py_ssize_t consumed ;
1039
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
1032
1040
PyObject * result ;
1033
1041
1034
1042
if (!PyArg_ParseTuple (args , "y#|z" , & data , & size , & errors ))
1035
1043
return NULL ;
1036
1044
1037
1045
result = PyUnicode_DecodeMBCSStateful (data , size , errors , & consumed );
1038
1046
if (!result ) {
1047
+ assert (consumed == UNINITIALIZED_SIZE );
1039
1048
return NULL ;
1040
1049
}
1041
1050
return Py_BuildValue ("(Nn)" , result , consumed );
@@ -1049,14 +1058,15 @@ unicode_decodecodepagestateful(PyObject *self, PyObject *args)
1049
1058
const char * data ;
1050
1059
Py_ssize_t size ;
1051
1060
const char * errors = NULL ;
1052
- Py_ssize_t consumed ;
1061
+ Py_ssize_t consumed = UNINITIALIZED_SIZE ;
1053
1062
PyObject * result ;
1054
1063
1055
1064
if (!PyArg_ParseTuple (args , "iy#|z" , & code_page , & data , & size , & errors ))
1056
1065
return NULL ;
1057
1066
1058
1067
result = PyUnicode_DecodeCodePageStateful (code_page , data , size , errors , & consumed );
1059
1068
if (!result ) {
1069
+ assert (consumed == UNINITIALIZED_SIZE );
1060
1070
return NULL ;
1061
1071
}
1062
1072
return Py_BuildValue ("(Nn)" , result , consumed );
0 commit comments