diff options
author | brooks <brooks@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-07-11 23:48:41 +0000 |
---|---|---|
committer | brooks <brooks@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-07-11 23:48:41 +0000 |
commit | 16c4a63b8599d34d1fa76b3c4db863b77ddf7477 (patch) | |
tree | 3ee591a0fb7f7a205df5d926d126446957b086e5 /libiberty | |
parent | 4a6cc5cd0f8609f7a2b8df4e5aa5ea1d00403784 (diff) |
2016-06-12 Brooks Moses <bmoses@google.com>
* cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length
VLAs.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238233 138bc75d-0d04-0410-961f-82ee72b054a4
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 d6b200e0ef2e..45b312bed5cd 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 09d646994665..7f664b9c5c0d 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; |