QHash: allow an empty QT_HASH_SEED env variable to reset

It's much easier to un-do a QT_HASH_SEED=0 by simply setting it to empty
in a command-line, as in:
  QT_HASH_SEED= ./appname

[ChangeLog][Important Behavior Changes] Previously, if the QT_HASH_SEED
environment variable was set but empty, Qt would interpret that as if it
had been set to 0, thus disabling the hash salting functionality. Since
this makes setting and unsetting this variable difficult in scripts, it
has been changed: if the variable is set but empty, it is interpreted
now as if it had not been set and the hash salting functionality is
enabled.

Change-Id: Id2983978ad544ff79911fffd1671f5473978a6bc
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Thiago Macieira 2021-04-01 23:03:47 -07:00
parent 9252b9bb92
commit 7709463b55

View File

@ -721,7 +721,7 @@ static uint qt_create_qhash_seed()
#ifndef QT_BOOTSTRAPPED
QByteArray envSeed = qgetenv("QT_HASH_SEED");
if (!envSeed.isNull()) {
if (!envSeed.isEmpty()) {
uint seed = envSeed.toUInt();
if (seed) {
// can't use qWarning here (reentrancy)