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

QUrl's qHash() is inconsistent with its operator==

XMLWordPrintable

    • 4
    • 304a9664d (dev), 238a4eb17 (dev), 8bc8f26e3 (6.10), 279f480e9 (6.10), 8d08bc241 (6.9), 97a206400 (tqtc/lts-6.8), 702051c07 (tqtc/lts-6.5), fc297e3da (6.9), 3b8c0b53f (tqtc/lts-6.8)
    • Foundation Sprint 127, Foundation Sprint 128, Foundation Sprint 129, Foundation Sprint 130

      There was an assymmetry between comparesEqual() and qHash() that I was finally able to exploit: op== checks !d and d->isEmpty(), while qHash() only checks !d, and then goes over all the QString fields, hashing them.

      This is a reproducer:

          QUrl null;
          QUrl other;
          other.setFragment("meep");
          other.setUrl(QString()); // doesn't overwrite d->fragment
      
          QCOMPARE_EQ(null, other);
          QCOMPARE_EQ(qHash(null), qHash(other)); // fails
      

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

            thiago Thiago Macieira
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: