fixed minor assertion flaw in lib/cmn/mbwc-str.c

This commit is contained in:
hyung-hwan 2019-05-07 07:39:49 +00:00
parent ebc9f5d29c
commit 3737a28cd3

View File

@ -419,15 +419,17 @@ int qse_wcstombswithcmgr (
{ {
qse_size_t n; qse_size_t n;
n = cmgr->wctomb (*p, mbsbuf, QSE_COUNTOF(mbsbuf)); n = cmgr->wctomb(*p, mbsbuf, QSE_COUNTOF(mbsbuf));
if (n == 0) if (n == 0)
{ {
ret = -1; ret = -1;
break; /* illegal character */ break; /* illegal character */
} }
/* it assumes that mbs is large enough to hold a character */ /* it assumes that mbsbuf is large enough to hold a character.
QSE_ASSERT (n <= QSE_COUNTOF(mbs)); * since mbsbuf is of the QSE_MBLEN_MAX size, the return value
* must not exceed the size of mbsbuf. */
QSE_ASSERT (n <= QSE_COUNTOF(mbsbuf));
p++; mlen += n; p++; mlen += n;
} }