diff options
author | Thierry Bastian <thierryb@filewave.com> | 2017-01-30 19:02:23 +0100 |
---|---|---|
committer | Thierry Bastian <thierryb@filewave.com> | 2017-02-03 15:37:58 +0000 |
commit | b8dbde10a065c3ba95b794b6d53ff62e8ca22ee7 (patch) | |
tree | f0871b2f0b9eb0e9744345bac9d8d2b41a6338d9 /src/corelib/io | |
parent | c7762f117819738a426dd091246a48befdcbef08 (diff) |
Fix data corruption when reading byte arrays from QSettings
On macOS, the code that read the plist is using
QByteArray::fromRawCFData. When we return the data directly
we need to detach the QByteArray so that it does not point
CFData's data that will get deallocated just after the call.
Task-number: QTBUG-58531
Change-Id: If829a304b986c99c8fc2aeeb992f2d539a4eef3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qsettings_mac.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index b79abfb874..0e3520441e 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -269,8 +269,10 @@ static QVariant qtValue(CFPropertyListRef cfvalue) // Fast-path for QByteArray, so that we don't have to go // though the expensive and lossy conversion via UTF-8. - if (!byteArray.startsWith('@')) + if (!byteArray.startsWith('@')) { + byteArray.detach(); return byteArray; + } const QString str = QString::fromUtf8(byteArray.constData(), byteArray.size()); return QSettingsPrivate::stringToVariant(str); |