mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
- Reindent a confusingly indented piece of code (no intended code changes
there) - Add missing DECREFs of inner-scope 'temp' variable - Add various missing DECREFs by changing 'return NULL' into 'goto onError' - Avoid double DECREF when last _PyUnicode_Resize() fails Coverity found one of the missing DECREFs, but oddly enough not the others.
This commit is contained in:
parent
318af47512
commit
a96affe1fc
1 changed files with 16 additions and 13 deletions
|
@ -7172,11 +7172,13 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
reslen += rescnt;
|
reslen += rescnt;
|
||||||
if (reslen < 0) {
|
if (reslen < 0) {
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
Py_DECREF(result);
|
PyErr_NoMemory();
|
||||||
return PyErr_NoMemory();
|
goto onError;
|
||||||
|
}
|
||||||
|
if (_PyUnicode_Resize(&result, reslen) < 0) {
|
||||||
|
Py_XDECREF(temp);
|
||||||
|
goto onError;
|
||||||
}
|
}
|
||||||
if (_PyUnicode_Resize(&result, reslen) < 0)
|
|
||||||
return NULL;
|
|
||||||
res = PyUnicode_AS_UNICODE(result)
|
res = PyUnicode_AS_UNICODE(result)
|
||||||
+ reslen - rescnt;
|
+ reslen - rescnt;
|
||||||
}
|
}
|
||||||
|
@ -7226,6 +7228,7 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
if (dict && (argidx < arglen) && c != '%') {
|
if (dict && (argidx < arglen) && c != '%') {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"not all arguments converted during string formatting");
|
"not all arguments converted during string formatting");
|
||||||
|
Py_XDECREF(temp);
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
|
@ -7237,12 +7240,12 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_PyUnicode_Resize(&result, reslen - rescnt) < 0)
|
||||||
|
goto onError;
|
||||||
if (args_owned) {
|
if (args_owned) {
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
}
|
}
|
||||||
Py_DECREF(uformat);
|
Py_DECREF(uformat);
|
||||||
if (_PyUnicode_Resize(&result, reslen - rescnt) < 0)
|
|
||||||
goto onError;
|
|
||||||
return (PyObject *)result;
|
return (PyObject *)result;
|
||||||
|
|
||||||
onError:
|
onError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue