Merge pull request #13488 from hyperlogic/bug-fix/qstring-from-script-engine

Fix for heap-corruption in Settings::saveAll due to implicitly shared QStrings
This commit is contained in:
John Conklin II 2018-06-28 09:56:51 -07:00 committed by GitHub
commit b07d317f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,5 +35,8 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar
}
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
Setting::Handle<QVariant>(setting).set(value);
// Make a deep-copy of the string.
// Dangling pointers can occur with QStrings that are implicitly shared from a QScriptEngine.
QString deepCopy = QString::fromUtf16(setting.utf16());
Setting::Handle<QVariant>(deepCopy).set(value);
}