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