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

Null Pointer Dereference in clearSubFocus

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.8.0
    • Widgets: GraphicsView
    • debian、deepin

    Description

      In each loop iteration, the code accesses the member of the parent pointer without first checking if the parent pointer is NULL; if the parent pointer becomes NULL in a certain iteration, then attempting to access parent->d_ptr or calling parent->isAncestorOf() will result in undefined behavior, I have used the demo to verify this, as attached, and the demo throws a program exception on close when the clearSubfocus with parent as nullptr, the demo will have a program exception on close, I submitted a patch to prevent this scenario and found it effective in practice.

      About Volker's comment, I have tried, when the parent is nullptr, while loop may exit, but here is the use of do...while, this will lead to enter the loop to determine the execution of the first time before, I verified and found that when the parent is nullptr is going to crash, about adding Q_ ASSERT(parent), I tried it and it also triggers a crash.

       

      The way I verified this issue was to assume that the parent is a nullptr and use a call to the clearSubfocus function to see if it would crash.

      Attachments

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

        Activity

          People

            vhilshei Volker Hilsheimer
            tsl115 Shilin Tian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes