aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:15:11 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:15:11 +0000
commitb8bc0ff76b12959e1aefafda407c03604605728c (patch)
tree446e102781c3c6ba28c0236407a02027e2d0996b /gcc/fortran/expr.c
parent6ef982714cf2a0a796cd55805ceeeaa07726a903 (diff)
downloadgcc-b8bc0ff76b12959e1aefafda407c03604605728c.zip
gcc-b8bc0ff76b12959e1aefafda407c03604605728c.tar.gz
gcc-b8bc0ff76b12959e1aefafda407c03604605728c.tar.bz2
re PR fortran/50409 (SIGSEGV in gfc_simplify_expr)
PR fortran/50409 * expr.c (gfc_simplify_expr): Substrings can't have negative length. * gcc/testsuite/gfortran.dg/string_5.f90: Improve testcase. From-SVN: r181181
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 504c7cf..f241455 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1853,8 +1853,8 @@ gfc_simplify_expr (gfc_expr *p, int type)
if (p->ref && p->ref->u.ss.end)
gfc_extract_int (p->ref->u.ss.end, &end);
- if (end < 0)
- end = 0;
+ if (end < start)
+ end = start;
s = gfc_get_wide_string (end - start + 2);
memcpy (s, p->value.character.string + start,