OSDN Git Service

check error code before result in QChar::decomposition() and QString::normalized()
authorIvailo Monev <xakepa10@laimg.moc>
Sat, 14 Dec 2019 23:53:46 +0000 (23:53 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sat, 14 Dec 2019 23:53:46 +0000 (23:53 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/tools/qchar.cpp
src/core/tools/qstring.cpp

index aeac441..dbec9c2 100644 (file)
@@ -1181,14 +1181,12 @@ QString QChar::decomposition(const uint ucs4)
     QString result(4, Qt::Uninitialized);
     const int decresult = unorm2_getDecomposition(normalizer, ucs4,
         reinterpret_cast<UChar*>(result.data()), result.size(), &errorcode);
-    if (Q_UNLIKELY(decresult < 1)) {
-        // no decomposition value
-        return QString();
-    }
-
     if (Q_UNLIKELY(U_FAILURE(errorcode))) {
         qWarning("QChar::decomposition: unorm2_getDecomposition() failed %s", u_errorName(errorcode));
         return QString();
+    } else if (Q_UNLIKELY(decresult < 1)) {
+        // no decomposition value
+        return QString();
     }
 
     result.resize(decresult);
index 80b4974..9e88ceb 100644 (file)
@@ -5750,12 +5750,12 @@ QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersi
     const int decresult = unorm2_normalize(normalizer,
         reinterpret_cast<const UChar*>(unicode()), srcsize,
         reinterpret_cast<UChar*>(result.data()), result.size(), &error);
-    if (Q_UNLIKELY(decresult < 1)) {
-        // no normalization value
-        return *this;
-    } else if (Q_UNLIKELY(U_FAILURE(error))) {
+    if (Q_UNLIKELY(U_FAILURE(error))) {
         qWarning("QString::normalized: unorm2_normalize() failed %s", u_errorName(error));
         return QString();
+    } else if (Q_UNLIKELY(decresult < 1)) {
+        // no normalization value
+        return *this;
     }
 
     result.resize(decresult);