diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-02-19 20:21:27 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-02-19 20:21:27 +0100 |
commit | af027826292351218785f893d1c42fe28ae3ed9f (patch) | |
tree | 59bf8daee2f7966f07bcad158bc2412c20853e51 | |
parent | 7d524a5de33910d7df7033c793afbad42444d2f5 (diff) | |
download | gcc-af027826292351218785f893d1c42fe28ae3ed9f.zip gcc-af027826292351218785f893d1c42fe28ae3ed9f.tar.gz gcc-af027826292351218785f893d1c42fe28ae3ed9f.tar.bz2 |
PR fortran/99147 - Sanitizer detects heap-use-after-free in gfc_add_flavor
Reverse order of conditions to avoid invalid read.
gcc/fortran/ChangeLog:
* symbol.c (gfc_add_flavor): Reverse order of conditions.
-rw-r--r-- | gcc/fortran/symbol.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 3b988d1b..e982374 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1772,8 +1772,8 @@ gfc_add_flavor (symbol_attribute *attr, sym_flavor f, const char *name, /* Copying a procedure dummy argument for a module procedure in a submodule results in the flavor being copied and would result in an error without this. */ - if (gfc_new_block && gfc_new_block->abr_modproc_decl - && attr->flavor == f && f == FL_PROCEDURE) + if (attr->flavor == f && f == FL_PROCEDURE + && gfc_new_block && gfc_new_block->abr_modproc_decl) return true; if (attr->flavor != FL_UNKNOWN) |