From 30620c7fa2b0f6a77d900ba7cdca7760f0e91540 Mon Sep 17 00:00:00 2001 From: Wang Rui <55612496+wr-web@users.noreply.github.com> Date: Sat, 9 May 2026 16:15:16 +0800 Subject: [PATCH 1/2] Fix Reference Counting (Use-After-Free) Bugs for PyTuple_SetItem --- pyeda/boolalg/espressomodule.c | 1 - 1 file changed, 1 deletion(-) diff --git a/pyeda/boolalg/espressomodule.c b/pyeda/boolalg/espressomodule.c index ca794756..3e55c0e9 100644 --- a/pyeda/boolalg/espressomodule.c +++ b/pyeda/boolalg/espressomodule.c @@ -205,7 +205,6 @@ _esprcov2pycov(int ninputs, int noutputs, set_family_t *F) for (i = 0; i < ninputs; i++) { pylong = PyLong_FromLong((long) GETINPUT(p, i)); if (PyTuple_SetItem(pyins, i, pylong) < 0) { - Py_DECREF(pylong); Py_DECREF(pyins); goto decref_pyset; } From 740a2f430641259d07da8c61f233798409a50fe6 Mon Sep 17 00:00:00 2001 From: Wang Rui <55612496+wr-web@users.noreply.github.com> Date: Sat, 9 May 2026 16:22:32 +0800 Subject: [PATCH 2/2] fix RC error --- pyeda/boolalg/espressomodule.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyeda/boolalg/espressomodule.c b/pyeda/boolalg/espressomodule.c index 3e55c0e9..f99a7609 100644 --- a/pyeda/boolalg/espressomodule.c +++ b/pyeda/boolalg/espressomodule.c @@ -218,7 +218,6 @@ _esprcov2pycov(int ninputs, int noutputs, set_family_t *F) for (i = 0; i < noutputs; i++) { pylong = PyLong_FromLong((long) GETOUTPUT(p, i)); if (PyTuple_SetItem(pyouts, i, pylong) < 0) { - Py_DECREF(pylong); goto decref_pyins_pyouts; } } @@ -232,7 +231,6 @@ _esprcov2pycov(int ninputs, int noutputs, set_family_t *F) } if (PyTuple_SetItem(pyimpl, 1, pyouts) < 0) { Py_DECREF(pyimpl); - Py_DECREF(pyouts); goto decref_pyset; } if (PySet_Add(pyset, pyimpl) < 0) {