Skip to content

Commit 297a4dd

Browse files
m-guptajungshik
authored andcommitted
i18n: Fix a crash because of unaligned memory accesses.
The buffer used in placement new should have the same alignment as the underlying type DecimalFormatProperties. Fixes login crashes in Chrome OS. BUG=chromium:865100 TEST=locally built chrome os image works. Change-Id: Ic71cb4e7962f1b9170e0a4ef00223767c621bc67 Reviewed-on: https://chromium-review.googlesource.com/1145582 Reviewed-by: Jungshik Shin <jshin@chromium.org>
1 parent 6ffa249 commit 297a4dd

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.chromium

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,8 @@ D. Local Modifications
260260
- upstream bug:
261261
https://unicode-org.atlassian.net/browse/ICU-13852
262262

263+
11. Align memory buffer used in Decimal Format
264+
265+
- patches/decimalformat_align.patch
266+
- upstream bug:
267+
https://unicode-org.atlassian.net/browse/ICU-20039

patches/decimalformat_align.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/source/i18n/number_decimfmtprops.cpp b/source/i18n/number_decimfmtprops.cpp
2+
index 6754fe19..b8994e56 100644
3+
--- a/source/i18n/number_decimfmtprops.cpp
4+
+++ b/source/i18n/number_decimfmtprops.cpp
5+
@@ -15,7 +15,7 @@ using namespace icu::number::impl;
6+
7+
namespace {
8+
9+
-char kRawDefaultProperties[sizeof(DecimalFormatProperties)];
10+
+alignas(DecimalFormatProperties) char kRawDefaultProperties[sizeof(DecimalFormatProperties)];
11+
12+
icu::UInitOnce gDefaultPropertiesInitOnce = U_INITONCE_INITIALIZER;
13+

source/i18n/number_decimfmtprops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace icu::number::impl;
1515

1616
namespace {
1717

18-
char kRawDefaultProperties[sizeof(DecimalFormatProperties)];
18+
alignas(DecimalFormatProperties) char kRawDefaultProperties[sizeof(DecimalFormatProperties)];
1919

2020
icu::UInitOnce gDefaultPropertiesInitOnce = U_INITONCE_INITIALIZER;
2121

0 commit comments

Comments
 (0)