gh-98831: Use DECREF_INPUTS() more (#102409)

This commit is contained in:
Guido van Rossum 2023-03-13 15:08:45 -07:00 committed by GitHub
parent 959ea2f9e9
commit 392f2ad3cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 57 deletions

View file

@ -1568,8 +1568,8 @@
PyObject **pieces = (stack_pointer - oparg);
PyObject *str;
str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
for (int i = 0; i < oparg; i++) {
Py_DECREF(pieces[i]);
for (int _i = oparg; --_i >= 0;) {
Py_DECREF(pieces[_i]);
}
if (str == NULL) { STACK_SHRINK(oparg); goto error; }
STACK_SHRINK(oparg);
@ -1665,9 +1665,8 @@
if (map == NULL)
goto error;
for (int i = 0; i < oparg; i++) {
Py_DECREF(values[i*2]);
Py_DECREF(values[i*2+1]);
for (int _i = oparg*2; --_i >= 0;) {
Py_DECREF(values[_i]);
}
if (map == NULL) { STACK_SHRINK(oparg*2); goto error; }
STACK_SHRINK(oparg*2);
@ -1732,10 +1731,10 @@
map = _PyDict_FromItems(
&PyTuple_GET_ITEM(keys, 0), 1,
values, 1, oparg);
Py_DECREF(keys);
for (int i = 0; i < oparg; i++) {
Py_DECREF(values[i]);
for (int _i = oparg; --_i >= 0;) {
Py_DECREF(values[_i]);
}
Py_DECREF(keys);
if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; }
STACK_SHRINK(oparg);
stack_pointer[-1] = map;