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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.10.0 Beta2, 6.11.0 FF
    • 5.0.2, 5.15.18, 6.2.13, 6.5.8, 6.7.3, 6.8.2, 6.9.0 RC
    • Core: URL Handling
    • None
    • 4
    • 304a9664d (dev), 238a4eb17 (dev), 8bc8f26e3 (6.10), 279f480e9 (6.10), 8d08bc241 (6.9), 97a206400 (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
      

        For Gerrit Dashboard: QTBUG-134896
        # Subject Branch Project Status CR V

            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: