X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eec47cc6c45a2d9a474cae9da897ebfdb0b7be21..356410fc88856bffdb7687d7d37e214a02af63e7:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index dfc8a40dac..960aa42566 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -214,11 +214,9 @@ wxMBConv::cMB2WC(const char *in, size_t inLen, size_t *outLen) const // not the most efficient algorithm but it shouldn't matter as normally // there are not many NULs in the string and so normally memcmp() // should stop on the first character - for ( const char *p = in; ; p++ ) - { - if ( memcmp(p, nul, nulLen) == 0 ) - break; - } + const char *p = in; + while ( memcmp(p, nul, nulLen) != 0 ) + p++; inLen = p - in + nulLen; } @@ -1655,10 +1653,19 @@ const char *wxMBConv_iconv::GetMBNul(size_t *nulLen) const wxMutexLocker lock(self->m_iconvMutex); #endif - size_t inLen = 1, + wchar_t *wnul = L""; + size_t inLen = sizeof(wchar_t), outLen = WXSIZEOF(m_nulBuf); - self->m_nulLen = iconv(w2m, ICONV_CHAR_CAST(L""), &inLen, - &self->m_nulBuf, &outLen); + char *in = (char *)wnul, + *out = self->m_nulBuf; + if ( iconv(w2m, &in, &inLen, &out, &outLen) == (size_t)-1 ) + { + self->m_nulLen = (size_t)-1; + } + else // ok + { + self->m_nulLen = out - m_nulBuf; + } } *nulLen = m_nulLen;