From 27fed63d9d60f63a540eb3c64716538a0397c935 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 8 Dec 2019 12:04:39 +0000 Subject: [PATCH] do not try to open codec twice if stateless open fails Signed-off-by: Ivailo Monev --- src/core/codecs/qicucodec.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/codecs/qicucodec.cpp b/src/core/codecs/qicucodec.cpp index ecb7789be..aca9b61d6 100644 --- a/src/core/codecs/qicucodec.cpp +++ b/src/core/codecs/qicucodec.cpp @@ -943,6 +943,7 @@ QIcuCodec::~QIcuCodec() QString QIcuCodec::convertToUnicode(const char *src, int length, QTextCodec::ConverterState *state) const { UConverter *conv = getConverter(state); + Q_ASSERT(conv); QString result(QMAXUSTRLEN(length), Qt::Uninitialized); UErrorCode error = U_ZERO_ERROR; @@ -973,6 +974,7 @@ QString QIcuCodec::convertToUnicode(const char *src, int length, QTextCodec::Con QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QTextCodec::ConverterState *state) const { UConverter *conv = getConverter(state); + Q_ASSERT(conv); const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); QByteArray result(maxbytes, Qt::Uninitialized); @@ -1104,6 +1106,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const state->d = ucnv_open(m_name, &error); if (Q_UNLIKELY(U_FAILURE(error))) { qWarning("QIcuCodec::getConverter: ucnv_open(%s) failed %s", m_name, u_errorName(error)); + return Q_NULLPTR; } else { error = U_ZERO_ERROR; if (state->flags & QTextCodec::ConvertInvalidToNull) { -- 2.11.0