Fix memory corruption in editor