Skip to content

Commit 9c3587b

Browse files
authored
Cherry-Pick 2 tickets after the ICU 68.2 release (#63)
This change cherry-picks two tickets from the upstream ICU repo that were merged after the ICU 68.2 release. - ICU-21427 Don't ignore already checked-in files under "tools/cldr/lib" - ICU-21118 check that dst and src are not null in uprv_memcpy The first one I had already done with #52, so this is mostly just making an update for the comments and to record it in the `changelog.md` file. The second one was fixed by @erik0686, and prevents undefined behavior in `ultag_parse`. CP: ICU-21118 check that dst and src are not null in uprv_memcpy https://unicode-org.atlassian.net/browse/ICU-21118 unicode-org/icu#1489 CP: ICU-21427 Don't ignore already checked-in files under "tools/cldr/lib" https://unicode-org.atlassian.net/browse/ICU-21427 unicode-org/icu#1500 Update changelog.md for cherry-picked tickets.
1 parent 9c749e1 commit 9c3587b

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ Changes/modifications compared to the upstream `maint/maint-68` branch.
1313
- Make `u_cleanup` a no-op for Windows OS ICU.
1414
- Conditionally set data file name based on `ICU_DATA_DIR_WINDOWS` to support Windows OS build with only a single data file.
1515
- Don't use the extended ICU data package for Windows OS build.
16+
17+
#### Changes cherry-picked from upstream tickets/PRs:
18+
19+
ICU-21427 Don't ignore already checked-in files under "tools/cldr/lib"
20+
- https://unicode-org.atlassian.net/browse/ICU-21427
21+
- https://github.com/unicode-org/icu/pull/1500
22+
23+
ICU-21118 check that dst and src are not null in uprv_memcpy
24+
- https://unicode-org.atlassian.net/browse/ICU-21118
25+
- https://github.com/unicode-org/icu/pull/1489

icu/icu4c/source/common/cmemory.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,25 @@
3131
#include <stddef.h>
3232
#include <string.h>
3333
#include "unicode/localpointer.h"
34+
#include "uassert.h"
3435

3536
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
3637
#include <stdio.h>
3738
#endif
3839

3940

40-
#define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size)
41-
#define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size)
41+
#define uprv_memcpy(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \
42+
U_ASSERT(dst != NULL); \
43+
U_ASSERT(src != NULL); \
44+
U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size); \
45+
} UPRV_BLOCK_MACRO_END
46+
47+
#define uprv_memmove(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \
48+
U_ASSERT(dst != NULL); \
49+
U_ASSERT(src != NULL); \
50+
U_STANDARD_CPP_NAMESPACE memmove(dst, src, size); \
51+
} UPRV_BLOCK_MACRO_END
52+
4253

4354
/**
4455
* \def UPRV_LENGTHOF

icu/icu4c/source/common/uloc_tag.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,10 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
20282028
*status = U_MEMORY_ALLOCATION_ERROR;
20292029
return NULL;
20302030
}
2031-
uprv_memcpy(tagBuf, tag, tagLen);
2031+
2032+
if (tagLen > 0) {
2033+
uprv_memcpy(tagBuf, tag, tagLen);
2034+
}
20322035
*(tagBuf + tagLen) = 0;
20332036

20342037
/* create a ULanguageTag */

icu/tools/cldr/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Exclude the Maven local repository but keep the lib directory and the top-level readme.
1+
# Exclude the Maven local repository but keep the lib directory and the top-level readme, scripts and build config.
22
/lib/**
33
!/lib/README.txt
44
!/lib/install-cldr-jars.sh

0 commit comments

Comments
 (0)