From: Brooks Moses Date: Mon, 11 Jul 2016 23:48:41 +0000 (-0700) Subject: cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length VLAs. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f39385351ac395127b36c7413a939ead037afe6;p=gcc.git cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length VLAs. 2016-06-12 Brooks Moses * cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length VLAs. From-SVN: r238233 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index d6b200e0ef2..45b312bed5c 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2016-06-12 Brooks Moses + + * cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length + VLAs. + 2016-05-31 Alan Modra * xmemdup.c (xmemdup): Use xmalloc rather than xcalloc. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 09d64699466..7f664b9c5c0 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -4128,8 +4128,12 @@ cplus_demangle_print_callback (int options, { #ifdef CP_DYNAMIC_ARRAYS - __extension__ struct d_saved_scope scopes[dpi.num_saved_scopes]; - __extension__ struct d_print_template temps[dpi.num_copy_templates]; + /* Avoid zero-length VLAs, which are prohibited by the C99 standard + and flagged as errors by Address Sanitizer. */ + __extension__ struct d_saved_scope scopes[(dpi.num_saved_scopes > 0) + ? dpi.num_saved_scopes : 1]; + __extension__ struct d_print_template temps[(dpi.num_copy_templates > 0) + ? dpi.num_copy_templates : 1]; dpi.saved_scopes = scopes; dpi.copy_templates = temps;