[#1767] avoid a nullpointer bug when the stack is null