fix possible crash in measure rest layout