summaryrefslogtreecommitdiff
path: root/libgfortran/generated/reshape_c16.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/reshape_c16.c')
-rw-r--r--libgfortran/generated/reshape_c16.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c
index 569b76ce4a8..ca588dc2c93 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -97,6 +97,8 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_16));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_COMPLEX_16);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}