From 3737a28cd3ef27633b0cdf24f76ecca26f400e3c Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 7 May 2019 07:39:49 +0000 Subject: [PATCH] fixed minor assertion flaw in lib/cmn/mbwc-str.c --- qse/lib/cmn/mbwc-str.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qse/lib/cmn/mbwc-str.c b/qse/lib/cmn/mbwc-str.c index e960026c..60fcb187 100644 --- a/qse/lib/cmn/mbwc-str.c +++ b/qse/lib/cmn/mbwc-str.c @@ -419,15 +419,17 @@ int qse_wcstombswithcmgr ( { qse_size_t n; - n = cmgr->wctomb (*p, mbsbuf, QSE_COUNTOF(mbsbuf)); + n = cmgr->wctomb(*p, mbsbuf, QSE_COUNTOF(mbsbuf)); if (n == 0) { ret = -1; break; /* illegal character */ } - /* it assumes that mbs is large enough to hold a character */ - QSE_ASSERT (n <= QSE_COUNTOF(mbs)); + /* it assumes that mbsbuf is large enough to hold a character. + * 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; }