From dd9dd295badd9d09184d9c3c0e7d9641c85dec6a Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Wed, 17 Jul 2024 13:21:06 -0700 Subject: [PATCH] Prevent uninitialized memory during a copy of joints and actuators. PiperOrigin-RevId: 653340718 Change-Id: Icc5ada05abd590504c157311a309f9b8493feac9 --- src/user/user_objects.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/user/user_objects.h b/src/user/user_objects.h index 66a6b7e9..1088f5b5 100644 --- a/src/user/user_objects.h +++ b/src/user/user_objects.h @@ -385,6 +385,12 @@ class mjCJoint_ : public mjCBase { protected: mjCBody* body; // joint's body + // variable used for temporarily storing the state of the joint + int qposadr_; // address of dof in data->qpos + int dofadr_; // address of dof in data->qvel + mjtNum qpos[7]; // qpos at the previous step + mjtNum qvel[6]; // qvel at the previous step + // variable-size data std::vector userdata_; std::vector spec_userdata_; @@ -420,11 +426,6 @@ class mjCJoint : public mjCJoint_, private mjsJoint { private: int Compile(void); // compiler; return dofnum void PointToLocal(void); - - int qposadr_; // address of dof in data->qpos - int dofadr_; // address of dof in data->qvel - mjtNum qpos[7]; // qpos at the previous step - mjtNum qvel[6]; // qvel at the previous step }; @@ -1362,6 +1363,11 @@ class mjCActuator_ : public mjCBase { protected: int trnid[2]; // id of transmission target + // variable used for temporarily storing the state of the actuator + int actadr_; // address of dof in data->act + int actnum_; // number of dofs in data->act + std::vector act; // act at the previous step + // variable-size data std::string plugin_name; std::string plugin_instance_name; @@ -1407,10 +1413,6 @@ class mjCActuator : public mjCActuator_, private mjsActuator { void NameSpace(const mjCModel* m); mjCBase* ptarget; // transmission target - - int actadr_; // address of dof in data->act - int actnum_; // number of dofs in data->act - std::vector act; // act at the previous step };