Skip to content

Commit

Permalink
ICU-22117 Replace uprv_strncpy() by uprv_memcpy()
Browse files Browse the repository at this point in the history
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 duckdb/duckdb#4391 for details.

Fixing the warning is important for us, because the checks in the duckdb repository treat all warnings as errors.
  • Loading branch information
krlmlr authored and markusicu committed Sep 10, 2022
1 parent e4df304 commit a48ae42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion icu4c/source/common/uloc_tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a48ae42

Please sign in to comment.