Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-24524

Division by zero in QTextEngine::positionInLigature

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.8.3
    • 4.8.0
    • GUI: Text handling
    • None
    • All
    • 74e777a76b9ac63107a32422c28ad79cd2217250

    Description

      Look at this code

          if (clusterLength) {
              const QGlyphLayout &glyphs = shapedGlyphs(si);
              QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos);
              // the approximate width of each individual element of the ligature
              QFixed perItemWidth = glyphWidth / clusterLength;
              QFixed left = x > edge ? edge : edge - glyphWidth;
              int n = ((x - left) / perItemWidth).floor().toInt();
              QFixed dist = x - left - n * perItemWidth;
              int closestItem = dist > (perItemWidth / 2) ? n + 1 : n;
              if (cursorOnCharacter && closestItem > 0)
                  closestItem--;
              int pos = si->position + clusterStart + closestItem;
              // Jump to the next charStop
              while (!attrs[pos].charStop && pos < end)
                  pos++;
              return pos;
          }
      

      If "glyphWidth==0" then "perItemWidth=0" and we have divizion by zero in "n" calculation.
      I got segfault error and had found this division by zero. I think this is the cause.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jiang Jiang Jiang
            laborer Sergey Gusarov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes