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

Crash when passing invalid input to QTextDocument::setMarkdown

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: Some future release
    • Fix Version/s: None
    • Component/s: GUI: Text handling
    • Environment:
      Ubuntu 18.04 LTS 64 bit
      gcc 7.3.0
      clang 6.0

      Description

      1. Build the attached demo project:
        #include <QFile>
        #include <QTextDocument>
        
        int main(int argc, char *argv[])
        {
            QFile f(argv[1]);
            f.open(QFile::ReadOnly);
            QTextDocument().setMarkdown(f.readAll());
            return 0;
        }
        

        Of course, this requires https://codereview.qt-project.org/214843/.

      2. Run it passing the filename of the attached malformed file as first parameter.
        The program crashes:
        1  QTextObject::docHandle              qtextobject.cpp           178  0x7ffff7a2ee52 
        2  QTextTableCell::firstPosition       qtexttable.cpp            251  0x7ffff7a7ac96 
        3  QTextTableCell::firstCursorPosition qtexttable.cpp            230  0x7ffff7a7ace8 
        4  QTextMarkdownImporter::cbEnterBlock qtextmarkdownimporter.cpp 204  0x7ffff7ab3a7f 
        5  CbEnterBlock                        qtextmarkdownimporter.cpp 60   0x7ffff7ab415a 
        6  md_process_table_cell               md4c.c                    4130 0x7ffff7ab2113 
        7  md_process_table_row                md4c.c                    4179 0x7ffff7ab23cd 
        8  md_process_table_block_contents     md4c.c                    4224 0x7ffff7ab25b7 
        9  md_process_leaf_block               md4c.c                    4471 0x7ffff7ab2833 
        10 md_process_all_blocks               md4c.c                    4551 0x7ffff7ab2a0c 
        11 md_process_doc                      md4c.c                    5881 0x7ffff7ab2c58 
        12 md_parse                            md4c.c                    5942 0x7ffff7ab2d7c 
        13 QTextMarkdownImporter::import       qtextmarkdownimporter.cpp 132  0x7ffff7ab3170 
        14 QTextDocument::setMarkdown          qtextdocument.cpp         3342 0x7ffff7a38007 
        15 main                                main.cpp                  8    0x555555554e22 
        

        Attachments

        1. backtrace.txt
          9 kB
        2. markdown.zip
          0.6 kB
        3. QTBUG-72936.md
          0.0 kB

          Issue Links

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

            Activity

              People

              • Assignee:
                srutledg Shawn Rutledge
                Reporter:
                rlohning Robert Löhning
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes