ICU-22117 Replace uprv_strncpy() by uprv_memcpy()

This fixes a warning on gcc 9.4.0, which is triggered because the third argument to strncpy() depends on the length of the second argument (but should actually indicate the buffer size). Replacing by memcpy() seems harmless because a null terminator is appended further below, and the buffer is sized to be "large enough" elsewhere.

See https://github.com/duckdb/duckdb/issues/4391 for details.

Fixing the warning is important for us, because the checks in the duckdb repository treat all warnings as errors.
This commit is contained in:
Kirill Müller 2022-08-15 06:57:22 +02:00 committed by Markus Scherer
parent e4df304367
commit a48ae42864

View file

@ -2124,7 +2124,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
if (*redundantTagEnd == '\0' || *redundantTagEnd == SEP) {
const char* preferredTag = REDUNDANT[i + 1];
size_t preferredTagLen = uprv_strlen(preferredTag);
uprv_strncpy(t->buf, preferredTag, preferredTagLen);
uprv_memcpy(t->buf, preferredTag, preferredTagLen);
if (*redundantTagEnd == SEP) {
uprv_memmove(tagBuf + preferredTagLen,
redundantTagEnd,