Message ID | 4E0901A7.90905@netcologne.de |
---|---|
State | New |
Headers | show |
On 06/27/2011 03:18 PM, Thomas Koenig wrote: > Hello world, > > the attached patch fixes PR 49479, a regression for 4.7 and 4.6. Test > case was supplied by Joost, the approach to the patch was suggested by > Tobias in comment#4 of the PR. The patch certainly looks safe enough. > > Regression-tested. OK for trunk and, after a couple of days, for 4.6? > > Thomas > OK, Jerry
Index: m4/reshape.m4 =================================================================== --- m4/reshape.m4 (Revision 175543) +++ m4/reshape.m4 (Arbeitskopie) @@ -101,6 +101,8 @@ if (ret->data == NULL) { + index_type alloc_size; + rs = 1; for (n = 0; n < rdim; n++) { @@ -111,7 +113,13 @@ rs *= rex; } ret->offset = 0; - ret->data = internal_malloc_size ( rs * sizeof ('rtype_name`)); + + if (unlikely (rs < 1)) + alloc_size = 1; + else + alloc_size = rs * sizeof ('rtype_name`); + + ret->data = internal_malloc_size (alloc_size); ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; }