@@ -1876,16 +1876,16 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
18761876 message = "malformed \\N character escape" ;
18771877 if (ucnhash_CAPI == NULL ) {
18781878 /* load the unicode data module */
1879- PyObject * m , * v ;
1879+ PyObject * m , * api ;
18801880 m = PyImport_ImportModule ("unicodedata" );
18811881 if (m == NULL )
18821882 goto ucnhashError ;
1883- v = PyObject_GetAttrString (m , "ucnhash_CAPI" );
1883+ api = PyObject_GetAttrString (m , "ucnhash_CAPI" );
18841884 Py_DECREF (m );
1885- if (v == NULL )
1885+ if (api == NULL )
18861886 goto ucnhashError ;
1887- ucnhash_CAPI = PyCObject_AsVoidPtr (v );
1888- Py_DECREF (v );
1887+ ucnhash_CAPI = PyCObject_AsVoidPtr (api );
1888+ Py_DECREF (api );
18891889 if (ucnhash_CAPI == NULL )
18901890 goto ucnhashError ;
18911891 }
@@ -1945,6 +1945,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
19451945 PyExc_UnicodeError ,
19461946 "\\N escapes not supported (can't load unicodedata module)"
19471947 );
1948+ Py_XDECREF (v );
19481949 Py_XDECREF (errorHandler );
19491950 Py_XDECREF (exc );
19501951 return NULL ;
@@ -3962,7 +3963,7 @@ Py_ssize_t PyUnicode_Tailmatch(PyObject *str,
39623963 return -1 ;
39633964 substr = PyUnicode_FromObject (substr );
39643965 if (substr == NULL ) {
3965- Py_DECREF (substr );
3966+ Py_DECREF (str );
39663967 return -1 ;
39673968 }
39683969
@@ -4429,7 +4430,7 @@ PyObject *PyUnicode_Splitlines(PyObject *string,
44294430 return list ;
44304431
44314432 onError :
4432- Py_DECREF (list );
4433+ Py_XDECREF (list );
44334434 Py_DECREF (string );
44344435 return NULL ;
44354436}
@@ -6679,6 +6680,10 @@ formatlong(PyObject *val, int flags, int prec, int type)
66796680 if (!str )
66806681 return NULL ;
66816682 result = _PyUnicode_New (len );
6683+ if (!result ) {
6684+ Py_DECREF (str );
6685+ return NULL ;
6686+ }
66826687 for (i = 0 ; i < len ; i ++ )
66836688 result -> str [i ] = buf [i ];
66846689 result -> str [len ] = 0 ;
@@ -6865,7 +6870,7 @@ PyObject *PyUnicode_Format(PyObject *format,
68656870 rescnt = fmtcnt + 100 ;
68666871 reslen += rescnt ;
68676872 if (_PyUnicode_Resize (& result , reslen ) < 0 )
6868- return NULL ;
6873+ goto onError ;
68696874 res = PyUnicode_AS_UNICODE (result ) + reslen - rescnt ;
68706875 -- rescnt ;
68716876 }
@@ -7163,6 +7168,7 @@ PyObject *PyUnicode_Format(PyObject *format,
71637168 rescnt = width + fmtcnt + 100 ;
71647169 reslen += rescnt ;
71657170 if (reslen < 0 ) {
7171+ Py_XDECREF (temp );
71667172 Py_DECREF (result );
71677173 return PyErr_NoMemory ();
71687174 }
0 commit comments