From ff2c3a4d8bbf06805478e01500f8934b5a34e84f Mon Sep 17 00:00:00 2001 From: Christian Heitman Date: Thu, 9 May 2024 11:54:10 -0300 Subject: [PATCH] Fix addCallback binding --- .../python/objects/pyTritonContext.cpp | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libtriton/bindings/python/objects/pyTritonContext.cpp b/src/libtriton/bindings/python/objects/pyTritonContext.cpp index f05db4d90..f6dbf2c0d 100644 --- a/src/libtriton/bindings/python/objects/pyTritonContext.cpp +++ b/src/libtriton/bindings/python/objects/pyTritonContext.cpp @@ -533,12 +533,13 @@ namespace triton { /* Call the callback */ PyObject* ret = PyObject_CallObject(cb, args); + /* Release args */ + Py_DECREF(args); + /* Check the call */ if (ret == nullptr) { throw triton::exceptions::PyCallbacks(); } - - Py_DECREF(args); /********* End of lambda *********/ }, cb)); break; @@ -565,12 +566,13 @@ namespace triton { /* Call the callback */ PyObject* ret = PyObject_CallObject(cb, args); + /* Release args */ + Py_DECREF(args); + /* Check the call */ if (ret == nullptr) { throw triton::exceptions::PyCallbacks(); } - - Py_DECREF(args); /********* End of lambda *********/ }, cb)); break; @@ -599,12 +601,13 @@ namespace triton { /* Call the callback */ PyObject* ret = PyObject_CallObject(cb, args); + /* Release args */ + Py_DECREF(args); + /* Check the call */ if (ret == nullptr) { throw triton::exceptions::PyCallbacks(); } - - Py_DECREF(args); /********* End of lambda *********/ }, cb)); break; @@ -633,12 +636,13 @@ namespace triton { /* Call the callback */ PyObject* ret = PyObject_CallObject(cb, args); + /* Release args */ + Py_DECREF(args); + /* Check the call */ if (ret == nullptr) { throw triton::exceptions::PyCallbacks(); } - - Py_DECREF(args); /********* End of lambda *********/ }, cb)); break; @@ -665,6 +669,9 @@ namespace triton { /* Call the callback */ PyObject* ret = PyObject_CallObject(cb, args); + /* Release args */ + Py_DECREF(args); + /* Check the call */ if (ret == nullptr) { throw triton::exceptions::PyCallbacks(); @@ -676,7 +683,6 @@ namespace triton { /* Update node */ node = PyAstNode_AsAstNode(ret); - Py_DECREF(args); return node; /********* End of lambda *********/ }, cb));