• Miklos Vajna's avatar
    tdf#105417 sw hyphenation: avoid infinite loop on zero-length last line · 1b6fa616
    Miklos Vajna yazdı
    This hang happened when the user executed Tools -> Language ->
    Hyphenation -> Hyphenate All.
    
    This problem is visible only if all of these conditions are met:
    - a line in a paragraph has a word that already contains a soft-hyphen,
      but not at the position where the automatic hyphenation would insert
      it
    - the last line ends with a word that can be hyphenated
    - there is a fly frame in the document
    
    In this case it happens during hyphenation that the layout has an
    additional empty line at the end (which is removed by the time the
    layout finishes), so we hit the case when SwTextFormatter::Hyphenate()
    skips the "if( m_pCurr->PrtWidth() && m_pCurr->GetLen() )" block.
    
    Normally hyphenation terminates when it iterates over the portions of the
    line and no overrun nor any existing hyphen portion are seen, but in
    this case that never happened. Fix the problem by terminating not only
    when we reach the end of the portion iteration, but also when the
    portion list is non-existing (has zero length).
    
    Change-Id: I71d4b040a2d4692ae6eb92807dbbbb42b077a0f8
    Reviewed-on: https://gerrit.libreoffice.org/33303Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
    Tested-by: 's avatarJenkins <ci@libreoffice.org>
    1b6fa616