According to the next code, 'pretty_name' may need additional bytes more
than 16. For simplify thinking and being extensible in future, extent it
to 256 bytes, directly.

It passes testsuite under fedora 20 x86_64-unknown-linux-gnu.


2014-11-17  Chen Gang  <gang.chen.5...@gmail.com>

        * ubsan.c (ubsan_type_descriptor): Extend 'pretty_name' space to
        avoid memory overflow.
---
 gcc/ubsan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 41cf546..12b05cd 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -376,7 +376,7 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style 
pstyle)
     tname = "<unknown>";
 
   /* Decorate the type name with '', '*', "struct", or "union".  */
-  pretty_name = (char *) alloca (strlen (tname) + 16 + deref_depth);
+  pretty_name = (char *) alloca (strlen (tname) + 256 + deref_depth);
   if (pstyle == UBSAN_PRINT_POINTER)
     {
       int pos = sprintf (pretty_name, "'%s%s%s%s%s%s%s",
-- 
1.9.3

Reply via email to