mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-12532 Avoid potential memory mis-alignment of stack-allocated decNum instance.
X-SVN-Rev: 38746
This commit is contained in:
parent
6cc82d7089
commit
54b8f0c928
1 changed files with 6 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015, International Business Machines
|
||||
* Copyright (C) 2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
* file name: visibledigits.cpp
|
||||
|
@ -84,8 +84,11 @@ double VisibleDigits::computeAbsDoubleValue() const {
|
|||
}
|
||||
|
||||
// stack allocate a decNumber to hold MAX_DBL_DIGITS+3 significant digits
|
||||
char rawNumber[sizeof(decNumber) + MAX_DBL_DIGITS+3];
|
||||
decNumber *numberPtr = (decNumber *) rawNumber;
|
||||
struct {
|
||||
decNumber decNum;
|
||||
char digits[MAX_DBL_DIGITS+3];
|
||||
} decNumberWithStorage;
|
||||
decNumber *numberPtr = &decNumberWithStorage.decNum;
|
||||
|
||||
int32_t mostSig = fInterval.getMostSignificantExclusive();
|
||||
int32_t mostSigNonZero = fExponent + fDigits.length();
|
||||
|
|
Loading…
Add table
Reference in a new issue