From bc06b8413f1db25ed18b4c16cbe39dac66a79034 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 24 Mar 2022 20:14:41 +0000 Subject: [PATCH] ofz: ensure unsigned index Change-Id: I38d6238a6eede0188f942229b2fb931614e56309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132042 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- hwpfilter/source/hbox.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx index e4f555efa320..2715da1c76bf 100644 --- a/hwpfilter/source/hbox.cxx +++ b/hwpfilter/source/hbox.cxx @@ -175,7 +175,7 @@ hchar_string DateCode::GetString() case '@': { static_assert((std::size(eng_mon) - 1) / 3 == 12); - size_t nIndex = (date[MONTH] - 1) % 12; + size_t nIndex = o3tl::make_unsigned(date[MONTH] - 1) % 12; memcpy(cbuf, eng_mon + nIndex * 3, 3); cbuf[3] = '.'; cbuf[4] = 0; @@ -183,7 +183,7 @@ hchar_string DateCode::GetString() } case '*': { - size_t nIndex = (date[MONTH] - 1) % std::size(en_mon); + size_t nIndex = o3tl::make_unsigned(date[MONTH] - 1) % std::size(en_mon); strncat(cbuf, en_mon[nIndex], sizeof(cbuf) - strlen(cbuf) - 1); break; } @@ -220,14 +220,14 @@ hchar_string DateCode::GetString() break; case '6': { - size_t nIndex = date[WEEK] % std::size(kor_week); + size_t nIndex = o3tl::make_unsigned(date[WEEK]) % std::size(kor_week); ret.push_back(kor_week[nIndex]); break; } case '^': { static_assert((std::size(eng_week) - 1) / 3 == 7); - size_t nIndex = date[WEEK] % 7; + size_t nIndex = o3tl::make_unsigned(date[WEEK]) % 7; memcpy(cbuf, eng_week + nIndex * 3, 3); cbuf[3] = '.'; cbuf[4] = 0; @@ -235,7 +235,7 @@ hchar_string DateCode::GetString() } case '_': { - size_t nIndex = date[WEEK] % std::size(en_week); + size_t nIndex = o3tl::make_unsigned(date[WEEK]) % std::size(en_week); strncat(cbuf, en_week[nIndex], sizeof(cbuf) - strlen(cbuf) - 1); break; } @@ -274,7 +274,7 @@ hchar_string DateCode::GetString() fmt++; if (*fmt == '6') { - size_t nIndex = date[WEEK] % std::size(china_week); + size_t nIndex = o3tl::make_unsigned(date[WEEK]) % std::size(china_week); ret.push_back(china_week[nIndex]); break; } -- 2.11.4.GIT