summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qsettings
diff options
context:
space:
mode:
authorThierry Bastian <thierryb@filewave.com>2017-01-30 19:02:23 +0100
committerThierry Bastian <thierryb@filewave.com>2017-02-03 15:37:58 +0000
commitb8dbde10a065c3ba95b794b6d53ff62e8ca22ee7 (patch)
treef0871b2f0b9eb0e9744345bac9d8d2b41a6338d9 /tests/auto/corelib/io/qsettings
parentc7762f117819738a426dd091246a48befdcbef08 (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 'tests/auto/corelib/io/qsettings')
-rw-r--r--tests/auto/corelib/io/qsettings/qsettings.qrc1
-rw-r--r--tests/auto/corelib/io/qsettings/resourcefile6.plist10
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp11
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qsettings/qsettings.qrc b/tests/auto/corelib/io/qsettings/qsettings.qrc
index c0be7e013f..c664a6f68c 100644
--- a/tests/auto/corelib/io/qsettings/qsettings.qrc
+++ b/tests/auto/corelib/io/qsettings/qsettings.qrc
@@ -5,6 +5,7 @@
<file>resourcefile3.ini</file>
<file>resourcefile4.ini</file>
<file>resourcefile5.ini</file>
+ <file>resourcefile6.plist</file>
<file>bom.ini</file>
</qresource>
</RCC>
diff --git a/tests/auto/corelib/io/qsettings/resourcefile6.plist b/tests/auto/corelib/io/qsettings/resourcefile6.plist
new file mode 100644
index 0000000000..6f994accac
--- /dev/null
+++ b/tests/auto/corelib/io/qsettings/resourcefile6.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>passwordData</key>
+ <data>
+ RBxVAAsDVsO/
+ </data>
+</dict>
+</plist>
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index f94349fd02..199ab442c4 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -178,6 +178,7 @@ private slots:
void testByteArray_data();
void testByteArray();
+ void testByteArrayNativeFormat();
void iniCodec();
void bom();
void embeddedZeroByte_data();
@@ -670,6 +671,16 @@ void tst_QSettings::testByteArray()
}
}
+void tst_QSettings::testByteArrayNativeFormat()
+{
+#ifndef Q_OS_MACOS
+ QSKIP("This test is specific to macOS plist reading.");
+#else
+ QSettings settings(":/resourcefile6.plist", QSettings::NativeFormat);
+ QCOMPARE(settings.value("passwordData"), QVariant(QByteArray::fromBase64("RBxVAAsDVsO/")));
+#endif
+}
+
void tst_QSettings::iniCodec()
{
{