From 13d4b027c15473b013f9ef39bf5e5241270501c2 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Sun, 4 Feb 2024 13:09:04 -0800 Subject: [PATCH] add missing Py_INCREFs for return values The previous commit failed CI because of this mistake, and I was probably just making a virtualenv mistake when I tried to test it locally. --- c_impl/blake3module.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/c_impl/blake3module.c b/c_impl/blake3module.c index b2a4873..4448445 100644 --- a/c_impl/blake3module.c +++ b/c_impl/blake3module.c @@ -214,7 +214,9 @@ static PyObject *Blake3_update(Blake3Object *self, PyObject *args) { Blake3_unlock_self(self); } - // success + // Success. We need to increment the refcount on self to return it, see: + // https://docs.python.org/3/extending/extending.html#ownership-rules. + Py_INCREF(self); ret = self; exit: @@ -267,6 +269,9 @@ static PyObject *Blake3_update_mmap(Blake3Object *self, PyObject *args, goto exit; } + // Success. We need to increment the refcount on self to return it, see: + // https://docs.python.org/3/extending/extending.html#ownership-rules. + Py_INCREF(self); ret = self; exit: