Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.0
-
None
-
-
727fab7d291d8d6e1b61a7faec4b4318f714d1e0 (qt/qtbase/dev) 8a4cac976044e925d938a9106bd299b7627ede20 (qt/qtbase/5.15)
Description
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.