diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-07-03 17:31:46 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-07-03 17:31:46 +0000 |
| commit | 312edb4768445003bca124bb8137feb0cc630c22 (patch) | |
| tree | 93211a6c9a8464863e08785ae2d8e30d52fba091 | |
| parent | d34ffc250e439c25b64ba64f7f9af27081657e5b (diff) | |
| download | ppe42-gcc-312edb4768445003bca124bb8137feb0cc630c22.tar.gz ppe42-gcc-312edb4768445003bca124bb8137feb0cc630c22.zip | |
2006-07-03 Ian Lance Taylor <ian@airs.com>
Paolo Carlini <pcarlini@suse.de>
* include/ext/rc_string_base.h (__rc_string_base::_S_max_size):
Increase by a factor of two.
* include/ext/sso_string_base.h (__sso_string_base::_S_max_size):
Likewise.
2006-07-03 Paolo Carlini <pcarlini@suse.de>
* include/ext/sso_string_base.h (__sso_string_base::_M_create): Never
allocate a string bigger than _S_max_size.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115155 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | libstdc++-v3/ChangeLog | 13 | ||||
| -rw-r--r-- | libstdc++-v3/include/ext/rc_string_base.h | 4 | ||||
| -rw-r--r-- | libstdc++-v3/include/ext/sso_string_base.h | 11 |
3 files changed, 23 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 67d3879c833..01868aaabcb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2006-07-03 Ian Lance Taylor <ian@airs.com> + Paolo Carlini <pcarlini@suse.de> + + * include/ext/rc_string_base.h (__rc_string_base::_S_max_size): + Increase by a factor of two. + * include/ext/sso_string_base.h (__sso_string_base::_S_max_size): + Likewise. + +2006-07-03 Paolo Carlini <pcarlini@suse.de> + + * include/ext/sso_string_base.h (__sso_string_base::_M_create): Never + allocate a string bigger than _S_max_size. + 2006-06-29 Benjamin Kosnik <bkoz@redhat.com> * include/Makefile.am (pch1_input, pch1_output_builddir, diff --git a/libstdc++-v3/include/ext/rc_string_base.h b/libstdc++-v3/include/ext/rc_string_base.h index c8bb9f3edca..9470db74fe3 100644 --- a/libstdc++-v3/include/ext/rc_string_base.h +++ b/libstdc++-v3/include/ext/rc_string_base.h @@ -177,9 +177,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT) // Solving for m: // m = ((npos - sizeof(_Rep)) / sizeof(_CharT)) - 1 - // In addition, this implementation quarters this amount. + // In addition, this implementation halfs this amount. enum { _S_max_size = (((static_cast<size_type>(-1) - sizeof(_Rep)) - / sizeof(_CharT)) - 1) / 4 }; + / sizeof(_CharT)) - 1) / 2 }; // Data Member (private): mutable typename _Util_Base::template _Alloc_hider<_Alloc> _M_dataplus; diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h index 0bf99cad53f..1282eb6e53e 100644 --- a/libstdc++-v3/include/ext/sso_string_base.h +++ b/libstdc++-v3/include/ext/sso_string_base.h @@ -61,9 +61,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // npos = m * sizeof(_CharT) + sizeof(_CharT) // Solving for m: // m = npos / sizeof(_CharT) - 1 - // In addition, this implementation quarters this amount. + // In addition, this implementation halfs this amount. enum { _S_max_size = (((static_cast<size_type>(-1) - / sizeof(_CharT)) - 1) / 4) }; + / sizeof(_CharT)) - 1) / 2) }; // Data Members (private): typename _Util_Base::template _Alloc_hider<_CharT_alloc_type> @@ -325,7 +325,12 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // meet amortized linear time requirements of the library: see // http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html. if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) - __capacity = 2 * __old_capacity; + { + __capacity = 2 * __old_capacity; + // Never allocate a string bigger than _S_max_size. + if (__capacity > size_type(_S_max_size)) + __capacity = size_type(_S_max_size); + } // NB: Need an array of char_type[__capacity], plus a terminating // null char_type() element. |

