From 49339fa475b6644efaffa2dd85126d171e125297 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sun, 20 Apr 2008 21:06:16 +0000 Subject: [PATCH] re PR fortran/35991 (run-time abort for CSHIFT of zero sized array) 2008-04-20 Jerry DeLisle PR fortran/35991 * intrinsics/cshift0.c (cshift0): Avoid divide by zero. From-SVN: r134491 --- libgfortran/ChangeLog | 5 +++++ libgfortran/intrinsics/cshift0.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 922eef795d2..8ef3e0fc55e 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2008-04-20 Jerry DeLisle + + PR fortran/35991 + * intrinsics/cshift0.c (cshift0): Avoid divide by zero. + 2008-04-20 Thomas Koenig PR libfortran/35960 diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c index 75762a8158f..aa466ff3b6b 100644 --- a/libgfortran/intrinsics/cshift0.c +++ b/libgfortran/intrinsics/cshift0.c @@ -202,7 +202,7 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array, rptr = ret->data; sptr = array->data; - shift = shift % (ssize_t)len; + shift = len == 0 ? 0 : shift % (ssize_t)len; if (shift < 0) shift += len;