Fixed undo bug

Fix a bug where adding a more labels to the label lists cause a crash,
due to memento size being smaller than the label list size