From 70236685b09e76b48949cc16fa2a7a1f8350bbb7 Mon Sep 17 00:00:00 2001 From: Nils Christian Roscher-Nielsen Date: Wed, 25 Nov 2009 18:21:36 +0100 Subject: Checks for len = 0 in QIconvCodec::convertFromUnicode iconv hangs when len is initially 0 on some Solaris platforms. This can be seen in the standarddialogs example when calling QFileDialog::getOpenFileName() for instance. Reviewed-by: ddenis Task-number: QTBUG-4976 --- src/corelib/codecs/qiconvcodec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 8c4cc82..0fb78d5 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -378,7 +378,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt } int invalidCount = 0; - do { + while (inBytesLeft != 0) { if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) { if (errno == EINVAL && convState) { // buffer ends in a surrogate @@ -418,7 +418,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt } } } - } while (inBytesLeft != 0); + } // reset to initial state iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); -- cgit v0.12