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