diff options
Diffstat (limited to 'src/Endstops/EndstopsManager.cpp')
-rw-r--r-- | src/Endstops/EndstopsManager.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Endstops/EndstopsManager.cpp b/src/Endstops/EndstopsManager.cpp index a3925ba6..461b92ac 100644 --- a/src/Endstops/EndstopsManager.cpp +++ b/src/Endstops/EndstopsManager.cpp @@ -293,7 +293,14 @@ GCodeResult EndstopsManager::HandleM574(GCodeBuffer& gb, const StringRef& reply, axisEndstops[lastAxisSeen] = nullptr; SwitchEndstop * const sw = new SwitchEndstop(lastAxisSeen, lastPosSeen); const GCodeResult rslt = sw->Configure(gb, reply); - axisEndstops[lastAxisSeen] = sw; + if (rslt == GCodeResult::ok) + { + axisEndstops[lastAxisSeen] = sw; + } + else + { + delete sw; + } return rslt; } |