summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-29 08:04:01 +0000
committerkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-29 08:04:01 +0000
commite919ffcee7037df29e4e65d2c665ec3498c6f963 (patch)
tree47e393d991c9aac28081ee86d635052b7f29cba7 /gcc/fortran/trans-array.c
parentd06bcb87348110926f05cf24cece54d9a61d02fd (diff)
gfortran: Fix allocation of diagnostig string (was too small).
The attached patch fixes an out of bound write to memory allocated with alloca() on the stack. This rarely ever happened because on one hand -fbounds-check needs to be enabled, and on the other hand alloca() used to allocate a few bytes extra most of the time so most of the time the excess write did no harm. gcc/fortran/ChangeLog: * trans-array.c (gfc_conv_array_ref): Fix allocation of diagnostic message (was too small). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238849 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index e95c8dd82353..7572755a7a6d 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -3332,7 +3332,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_expr *expr,
if (ref->type == REF_ARRAY && &ref->u.ar == ar)
break;
if (ref->type == REF_COMPONENT)
- len += 1 + strlen (ref->u.c.component->name);
+ len += 2 + strlen (ref->u.c.component->name);
}
var_name = XALLOCAVEC (char, len);