diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-11-10 20:30:27 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-11-10 20:30:27 +0100 |
commit | abc2f01914d6c4703de26c402fb579a9a2d0dba4 (patch) | |
tree | edb997ffe0cf1b326b78d2f480bb137c0fcf12c0 /gcc/fortran/simplify.c | |
parent | b83705b477858ba683b99fa61ff9ff83bc5be265 (diff) | |
download | gcc-abc2f01914d6c4703de26c402fb579a9a2d0dba4.zip gcc-abc2f01914d6c4703de26c402fb579a9a2d0dba4.tar.gz gcc-abc2f01914d6c4703de26c402fb579a9a2d0dba4.tar.bz2 |
Fortran: avoid NULL pointer dereferences
CLASS(), PARAMETER is not yet properly implemented in gfortran. Using it
in declarations could lead to subsequent NULL pointer dereferences during
checking or simplification of expressions involving those CLASS variables.
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
* check.c (gfc_check_shape): Avoid NULL pointer dereference on
missing ref.
* simplify.c (gfc_simplify_cshift): Avoid NULL pointer dereference
when shape not set.
(gfc_simplify_transpose): Likewise.
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index d675f2c..6a6b3fb 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -2109,6 +2109,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim) else which = 0; + if (array->shape == NULL) + return NULL; + gfc_array_size (array, &size); arraysize = mpz_get_ui (size); mpz_clear (size); @@ -8174,6 +8177,9 @@ gfc_simplify_transpose (gfc_expr *matrix) gcc_assert (matrix->rank == 2); + if (matrix->shape == NULL) + return NULL; + result = gfc_get_array_expr (matrix->ts.type, matrix->ts.kind, &matrix->where); result->rank = 2; |