diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-24 20:14:41 +0000 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-28 10:17:28 +0200 |
commit | 39c7f8c9cbe15c42b8bff6301a02de6315dc2416 (patch) | |
tree | 34cef5d56fe826b0edf905b19c1134d38af96c6d | |
parent | e890f54dbac57f3ab5acf4fbd31222095d3e8ab6 (diff) |
ofz: ensure unsigned index
Change-Id: I38d6238a6eede0188f942229b2fb931614e56309
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132043
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | hwpfilter/source/hbox.cxx | 12 |
1 files 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; } |