I have the following code:
element.clear();
element.setTagName(\"accountpoint\");
element.setAttribute(\"code\", QString(ID_CONST)+serial);
element.setAttrib
I ran into this issue when trying to store xml setting data in git. In this case (in order to get a sane diff) it is important to store the xml using the same attribute ordering each time. The code base was several years old, using the deprecated Qt Xml instead of the newer QXmlStreamWriter.
The trick of setting the QT_HASH_SEED environment variable (from @MrEricSir's answer) works well in this case. However, it can also be done directly in code, like in this example:
qSetGlobalQHashSeed(42); // set a fixed hash value
QDomDocument doc = QDomDocument();
// add stuff to doc...
// ...
// save doc to file:
QFile file(filename);
QTextStream stream(&file);
stream << doc.toString(4);
file.close();
// reset hash seed with new random value.
qSetGlobalQHashSeed(-1);
This way, the rest of your application works as before, thus avoiding exposure to algorithmic complexity attacks.