From 2a87c3ddb8221a46a873ef038bf3f6260201cb80 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 10 Dec 2021 10:08:15 -0800 Subject: [PATCH] Addressed PR comments. --- python/repeated.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/repeated.c b/python/repeated.c index d04ad70950..837b2d0080 100644 --- a/python/repeated.c +++ b/python/repeated.c @@ -316,8 +316,8 @@ static int PyUpb_RepeatedContainer_SetSubscript( PyObject* seq = PySequence_Fast(value, "must assign iterable to extended slice"); PyObject* item = NULL; - if (!seq) goto err; int ret = -1; + if (!seq) goto err; if (PySequence_Size(seq) != count) { PyErr_Format(PyExc_ValueError, "attempt to assign sequence of size %zd to extended slice " @@ -331,6 +331,8 @@ static int PyUpb_RepeatedContainer_SetSubscript( if (!item) goto err; // XXX: if this fails we can leave the list partially mutated. if (!PyUpb_PyToUpb(item, f, &msgval, arena)) goto err; + Py_DECREF(item); + item = NULL; upb_array_set(arr, idx, msgval); } ret = 0;