fixup a memory leak in actions/undo.cpp

This fixes up commit
https://github.com/wesnoth/wesnoth/commit/64e69cd6#diff-f925ac8cf45da1ab4547b483379d9b75R253

Issue spotted by coverity static analysis tool.