summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>2018-05-03 15:03:17 +0300
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>2018-05-04 22:18:24 +0300
commita25e17bd53831d2478d7e3cf0e1f65b1be69d31c (patch)
tree50456bedfdee21adaf9500c6a225cae9d86f6a84
parent6df0a8755638433065a4a65505ae539c5c5303d1 (diff)
downloadlinaro-gcc-a25e17bd53831d2478d7e3cf0e1f65b1be69d31c.tar.gz
linaro-gcc-a25e17bd53831d2478d7e3cf0e1f65b1be69d31c.tar.bz2
linaro-gcc-a25e17bd53831d2478d7e3cf0e1f65b1be69d31c.zip
Fix string::operator= with disable sso.
Found this case during aarch64 build: __str may be null and setting new length with clear() will cause error. Change-Id: I93ad10b4c15ed293d1228243591a1ec1ed22c4d9
-rw-r--r--libstdc++-v3/include/bits/basic_string.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 61e16ae4d94..7a899c16dd7 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -940,13 +940,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
// Replace allocator if POCMA is true.
std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
+ pointer __data = nullptr;
if (!__str._M_is_local()
&& (_Alloc_traits::_S_propagate_on_move_assign()
|| _Alloc_traits::_S_always_equal()))
{
__annotate_delete();
__str.__annotate_delete();
- pointer __data = nullptr;
size_type __capacity;
#ifdef _GLIBCXX_HAS_ASAN
size_type __length;
@@ -1007,7 +1007,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
else {
assign(__str);
}
- __str.clear();
+#ifdef _GLIBCXX_DISABLE_STRING_SSO
+ if (__data)
+#endif
+ __str.clear();
#ifdef _GLIBCXX_HAS_ASAN
_M_capacity(__str_capacity);
#ifdef _GLIBCXX_DISABLE_STRING_SSO