Skip to content

Commit 597be1c

Browse files
committed
More cleanup
1 parent b71204e commit 597be1c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Python/marshal.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,34 +512,32 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
512512
p->error = WFERR_NOMEMORY;
513513
return;
514514
}
515-
PyObject *pair = NULL;
516515
while (_PySet_NextEntry(v, &pos, &value, &hash)) {
517516
PyObject *dump = PyMarshal_WriteObjectToString(value, p->version);
518517
if (dump == NULL) {
519518
p->error = WFERR_UNMARSHALLABLE;
520519
goto anyset_done;
521520
}
522-
pair = PyTuple_Pack(2, dump, value);
521+
PyObject *pair = PyTuple_Pack(2, dump, value);
523522
Py_DECREF(dump);
524-
if (pair == NULL || PyList_Append(pairs, pair)) {
523+
int error = pair == NULL || PyList_Append(pairs, pair);
524+
Py_XDECREF(pair);
525+
if (error) {
525526
p->error = WFERR_NOMEMORY;
526527
goto anyset_done;
527528
}
528-
Py_CLEAR(pair);
529529
}
530530
if (PyList_Sort(pairs)) {
531531
p->error = WFERR_UNMARSHALLABLE;
532532
goto anyset_done;
533533
}
534534
for (Py_ssize_t i = 0; i < n; i++) {
535-
pair = PyList_GET_ITEM(pairs, i);
535+
PyObject *pair = PyList_GET_ITEM(pairs, i);
536536
value = PyTuple_GET_ITEM(pair, 1);
537537
w_object(value, p);
538-
pair = NULL;
539538
}
540539
anyset_done:
541-
Py_XDECREF(pairs);
542-
Py_XDECREF(pair);
540+
Py_DECREF(pairs);
543541
}
544542
else if (PyCode_Check(v)) {
545543
PyCodeObject *co = (PyCodeObject *)v;

0 commit comments

Comments
 (0)