diff options
author | Brooks Moses <bmoses@google.com> | 2016-07-11 16:48:41 -0700 |
---|---|---|
committer | Brooks Moses <brooks@gcc.gnu.org> | 2016-07-11 16:48:41 -0700 |
commit | 3f39385351ac395127b36c7413a939ead037afe6 (patch) | |
tree | 3ee591a0fb7f7a205df5d926d126446957b086e5 /libiberty | |
parent | 3d56e6a465a1fab02df9648c9dca41e98fabbae0 (diff) | |
download | gcc-3f39385351ac395127b36c7413a939ead037afe6.zip gcc-3f39385351ac395127b36c7413a939ead037afe6.tar.gz gcc-3f39385351ac395127b36c7413a939ead037afe6.tar.bz2 |
cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length VLAs.
2016-06-12 Brooks Moses <bmoses@google.com>
* cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length
VLAs.
From-SVN: r238233
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 5 | ||||
-rw-r--r-- | libiberty/cp-demangle.c | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index d6b200e..45b312b 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2016-06-12 Brooks Moses <bmoses@google.com> + + * cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length + VLAs. + 2016-05-31 Alan Modra <amodra@gmail.com> * xmemdup.c (xmemdup): Use xmalloc rather than xcalloc. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 09d6469..7f664b9 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; |