From bf3696e5b4f91cc97fa6ea33fcc5f38712e1a74e Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 22 Jul 2019 09:28:27 -0700 Subject: [PATCH] fix a leak in previous commit --- examples/pybullet/pybullet.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 28be6a25d..1065c166d 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -4301,6 +4301,8 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg ) { Py_DECREF(jointIndicesSeq); + PyErr_SetString(SpamError, "Number of targetValues and targetVelocities needs to match number of indices."); + return NULL; } @@ -4313,6 +4315,10 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg int jointIndex = pybullet_internalGetIntFromSequence(jointIndicesSeq, i); if ((jointIndex >= numJoints) || (jointIndex < 0)) { + if (targetPositionsSeq) + Py_DECREF(targetPositionsSeq); + if (targetVelocitiesSeq) + Py_DECREF(targetVelocitiesSeq); Py_DECREF(jointIndicesSeq); PyErr_SetString(SpamError, "Joint index out-of-range."); return NULL; @@ -4389,6 +4395,11 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg if (targetPositionSize == 0 && targetVelocitySize == 0) { + if (targetPositionsSeq) + Py_DECREF(targetPositionsSeq); + if (targetVelocitiesSeq) + Py_DECREF(targetVelocitiesSeq); + Py_DECREF(jointIndicesSeq); PyErr_SetString(SpamError, "Expected an position and/or velocity list."); return NULL; } @@ -4405,8 +4416,14 @@ static PyObject* pybullet_resetJointStatesMultiDof(PyObject* self, PyObject* arg } } } - statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle); + + if (targetPositionsSeq) + Py_DECREF(targetPositionsSeq); + if (targetVelocitiesSeq) + Py_DECREF(targetVelocitiesSeq); Py_DECREF(jointIndicesSeq); + statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle); + } } Py_INCREF(Py_None);