From 8a74c5112aa81c5638b14d8b5285e6ef8474a195 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 15 Feb 2011 18:50:38 +0100 Subject: Fixed QString creation for certain cases in QLocale If the data that was requested is missing from CLDR, then we do not need to try to create QString out of empty data, but return a shared_empty QString instead. i.e. QString::fromRawData(data, 0/*length==0*/) - instead of doing that just return a default constructed QString. Reviewed-by: Zeno Albisser --- src/corelib/tools/qlocale.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 3f19c27..5debabb 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1522,12 +1522,14 @@ static QString getLocaleListData(const ushort *data, int size, int index) const ushort *end = data; while (size > 0 && *end != separator) ++end, --size; + if (end-data == 0) + return QString(); return QString::fromRawData(reinterpret_cast(data), end-data); } static inline QString getLocaleData(const ushort *data, int size) { - return QString::fromRawData(reinterpret_cast(data), size); + return size ? QString::fromRawData(reinterpret_cast(data), size) : QString(); } -- cgit v0.12