public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9368] Fortran: avoid NULL pointer dereference on missing or bad dummy arguments Date: Thu, 9 Dec 2021 22:17:09 +0000 (GMT) [thread overview] Message-ID: <20211209221709.59CF83858430@sourceware.org> (raw) https://gcc.gnu.org/g:81ffb19017daf7197445ed0793e925674a3970d5 commit r11-9368-g81ffb19017daf7197445ed0793e925674a3970d5 Author: Harald Anlauf <anlauf@gmx.de> Date: Wed Dec 8 21:14:19 2021 +0100 Fortran: avoid NULL pointer dereference on missing or bad dummy arguments gcc/fortran/ChangeLog: PR fortran/103609 * symbol.c (gfc_sym_get_dummy_args): Catch NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/103609 * gfortran.dg/pr103609.f90: New test. (cherry picked from commit b77968a70537429b4f548f90c369d26e6b6943cc) Diff: --- gcc/fortran/symbol.c | 3 +++ gcc/testsuite/gfortran.dg/pr103609.f90 | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 6d61bf4982b..c2dad08d878 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -5253,6 +5253,9 @@ gfc_sym_get_dummy_args (gfc_symbol *sym) { gfc_formal_arglist *dummies; + if (sym == NULL) + return NULL; + dummies = sym->formal; if (dummies == NULL && sym->ts.interface != NULL) dummies = sym->ts.interface->formal; diff --git a/gcc/testsuite/gfortran.dg/pr103609.f90 b/gcc/testsuite/gfortran.dg/pr103609.f90 new file mode 100644 index 00000000000..57f6a3b1531 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103609.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/103609 - ICE in gfc_sym_get_dummy_args +! Contributed by G.Steinmetz + +program p + implicit none + integer :: i + do i = 1, 2 + call s + end do +contains + subroutine s + call sub(x) ! { dg-error "has no IMPLICIT type" } + end +end
reply other threads:[~2021-12-09 22:17 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211209221709.59CF83858430@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).