Ensure last XML is freed after tests.

This fixes undetected memory leaks in tests calling mj_loadXML.

Additionally, a specific test for `mj_freeLastXML` is introduced.

PiperOrigin-RevId: 764294041
Change-Id: I8b5a5683d8431ed920cdd52b06ad3515d8e19e14
This commit is contained in:
Alessio Quaglino
2025-05-28 09:25:45 -07:00
committed by Copybara-Service
parent 18b0e68a5a
commit 287f46b220
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -53,6 +53,9 @@ class MujocoErrorTestGuard {
// By default, any MuJoCo operation which triggers a warning or error will
// trigger a test failure.
class MujocoTest : public ::testing::Test {
public:
~MujocoTest() { mj_freeLastXML(); }
private:
MujocoErrorTestGuard error_guard;
};