[gcc r9-9151] PR fortran/96381 - invalid read in gfc_find_derived_vtab
Harald Anlauf
anlauf@gcc.gnu.org
Mon Jan 4 21:06:09 GMT 2021
https://gcc.gnu.org/g:2bfcf6011a6cdce0439e3d1b94bcb5fcf078f4c2
commit r9-9151-g2bfcf6011a6cdce0439e3d1b94bcb5fcf078f4c2
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Jan 1 18:55:41 2021 +0100
PR fortran/96381 - invalid read in gfc_find_derived_vtab
An invalid declaration of a CLASS instance can lead to an internal state
with inconsistent attributes during parsing that needs to be handled with
sufficient care when processing subsequent statements. Avoid a lookup of
the vtab entry for such cases.
gcc/fortran/ChangeLog:
* class.c (gfc_find_vtab): Add check on attribute is_class.
(cherry picked from commit d816b0c144d15e6570eb5b124b9f3ccbe3d40082)
Diff:
---
gcc/fortran/class.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index ab3df62170a..1a5bcfae3c0 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -2885,7 +2885,9 @@ gfc_find_vtab (gfc_typespec *ts)
case BT_DERIVED:
return gfc_find_derived_vtab (ts->u.derived);
case BT_CLASS:
- if (ts->u.derived->components && ts->u.derived->components->ts.u.derived)
+ if (ts->u.derived->attr.is_class
+ && ts->u.derived->components
+ && ts->u.derived->components->ts.u.derived)
return gfc_find_derived_vtab (ts->u.derived->components->ts.u.derived);
else
return NULL;
More information about the Gcc-cvs
mailing list