Skip to content

Commit be7094e

Browse files
authored
[libc++][C++03] cherry-pick #126273 (#157095)
1 parent 528b13d commit be7094e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libcxx/include/__cxx03/locale

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,6 +2460,8 @@ _LIBCPP_HIDE_FROM_ABI void __double_or_nothing(unique_ptr<_Tp, void (*)(void*)>&
24602460
__throw_bad_alloc();
24612461
if (__owns)
24622462
__b.release();
2463+
else
2464+
std::memcpy(__t, __b.get(), __cur_cap);
24632465
__b = unique_ptr<_Tp, void (*)(void*)>(__t, free);
24642466
__new_cap /= sizeof(_Tp);
24652467
__n = __b.get() + __n_off;
@@ -2655,20 +2657,22 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get(
26552657
char_type __atoms[sizeof(__src) - 1];
26562658
__ct.widen(__src, __src + (sizeof(__src) - 1), __atoms);
26572659
char __nbuf[__bz];
2658-
char* __nc = __nbuf;
2660+
char* __nc = __nbuf;
2661+
const char* __nc_in = __nc;
26592662
unique_ptr<char, void (*)(void*)> __h(nullptr, free);
26602663
if (__wn - __wb.get() > __bz - 2) {
26612664
__h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
26622665
if (__h.get() == nullptr)
26632666
__throw_bad_alloc();
2664-
__nc = __h.get();
2667+
__nc = __h.get();
2668+
__nc_in = __nc;
26652669
}
26662670
if (__neg)
26672671
*__nc++ = '-';
26682672
for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
26692673
*__nc = __src[std::find(__atoms, std::end(__atoms), *__w) - __atoms];
26702674
*__nc = char();
2671-
if (sscanf(__nbuf, "%Lf", &__v) != 1)
2675+
if (sscanf(__nc_in, "%Lf", &__v) != 1)
26722676
__throw_runtime_error("money_get error");
26732677
}
26742678
if (__b == __e)

libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_overlong.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// Ensure that money_get::do_get correct works when the input doesn't fit into the stack buffer
1717
// (100 characters currently).
1818

19-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
20-
2119
#include <cassert>
2220
#include <cstddef>
2321
#include <ios>

0 commit comments

Comments
 (0)