]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/reshape_i16.c
Introduce xmallocarray, an overflow checking variant of xmalloc.
[thirdparty/gcc.git] / libgfortran / generated / reshape_i16.c
index f05a93727ebce734dc0fdb2200f878907f0fb6ca..b766e1a9acf2af67a53ec2386c8d4078a82e199c 100644 (file)
@@ -111,11 +111,11 @@ reshape_16 (gfc_array_i16 * const restrict ret,
       ret->offset = 0;
 
       if (unlikely (rs < 1))
-        alloc_size = 1;
+        alloc_size = 0;
       else
-        alloc_size = rs * sizeof (GFC_INTEGER_16);
+        alloc_size = rs;
 
-      ret->base_addr = xmalloc (alloc_size);
+      ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16));
       ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
     }