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

Using find() and end() in QCborMap can cause crash after copying of the map

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.15.1
    • 5.15.0
    • Core: Other
    • None
    • All
    • 727fab7d291d8d6e1b61a7faec4b4318f714d1e0 (qt/qtbase/dev) 8a4cac976044e925d938a9106bd299b7627ede20 (qt/qtbase/5.15)

      The following code causes a fatal error, QMap doesn't have this problem.

          QCborMap mapBeforeCopy;
          map[1] = "Value1";
          map[2] = "Value2";
      
          QCborMap copyMap(mapBeforeCopy);
      
          QCborMap::iterator it = copyMap.find(3);
          if(it != copyMap.end()){        //always true!
              it.value() = "Value4";      //fatal error
          }
      

      Function QCborMap::find() doesn't call detach() if key is not in the map, so the iterator "it" points to the end of "mapBeforeCopy". But QCborMap::end() always calls detach() and iterator returned by it points to the end of "copyMap", so these iterators are always not equal.

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

            thiago Thiago Macieira
            ilyak Пр Нп
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes