This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Fix libstdc++/11352
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 30 Jun 2003 20:27:52 +0200
- Subject: [Patch] Fix libstdc++/11352
Hi,
the actual seg fault is difficult to reproduce but the problem
seems to me simple and and the fix obviously correct: before
accessing __olds[1] we must make sure that __olds has at
least two positions.
Tested x86-linux, ok trunk and 3_3?
Paolo.
/////////
2003-06-30 David Asher <david.asher@cavium.com>
PR libstdc++/11352
* include/bits/locale_facets.tcc (__pad::_S_pad): Don't
access past the end of the __olds array.
diff -urN libstdc++-v3-orig/include/bits/locale_facets.tcc libstdc++-v3/include/bits/locale_facets.tcc
--- libstdc++-v3-orig/include/bits/locale_facets.tcc 2003-06-27 09:25:37.000000000 +0200
+++ libstdc++-v3/include/bits/locale_facets.tcc 2003-06-30 19:53:57.000000000 +0200
@@ -2206,8 +2206,9 @@
|| _Traits::eq(__olds[0], __plus);
bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
- && (_Traits::eq(__ctype.widen('x'), __olds[1])
- || _Traits::eq(__ctype.widen('X'), __olds[1]));
+ && ((__oldlen > 1)
+ && (_Traits::eq(__ctype.widen('x'), __olds[1])
+ || _Traits::eq(__ctype.widen('X'), __olds[1])));
if (__testhex)
{
__news[0] = __olds[0];