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

QList<T>::operator= crash

    XMLWordPrintable

Details

    • a2f83283a64460ca26530321f8eb64f3ddfe4c8b

    Description

      Consider the following code:

      struct Node { QList<Node> children; };
      int main(int, char**)
      {
          QList<Node> nodeList;
          nodeList << Node();
          nodeList = nodeList.first().children; //<< crashes
      }
      

      The application crashes in the assignment operator of QList. I've done some research and found out, that the list first destroys its content and then do the actual copy operation. But in the example above, the source (nodeList.first().children) is a part of the "old" content of the destination list (nodeList).

      Sometimes the code seems to work fine (no crash and desired results) but you get always an error if you run it with a memory analysis tool like valgrind.

      Attachments

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

        Activity

          People

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            thiloa Thilo Ackermann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes