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

QMultiHash::operator== is broken

XMLWordPrintable

    • 838edd9c48284b97dfc22cf3644bb082035a9a93 (qt/qtbase/dev) 682b19a8c7cd2bba669064f9e99d1acfe835326f (qt/qtbase/6.2)

      This code crashes:

      #include <QBluetoothUuid>
      
      int main(int argc, char** argv) {
          typedef QMultiHash<QBluetoothUuid, QByteArray> Hash;
      
          Hash a;
          a.insert(QBluetoothUuid(quint16(32)), QByteArray());
          Hash b;
          b.insert(QBluetoothUuid(quint16(33)), QByteArray());
      
          if (a == b){
              qDebug() << "equal";
          } else {
              qDebug() << "unequal";
          }
      
          return 0;
      }
      

      The reason seems to be in its implementation. Here, it should "return false" in line 1324:

      but the "if (i == e->ned())" can never trigger. The reason is that "end()" returns an iterator with the "d" pointer set to "nullptr". But all code pathes in "find()" return an iterator with the "d" pointer set to "this"

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

            andreasbuhr Andreas Buhr
            andreasbuhr Andreas Buhr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes