public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2051] analyzer: fix for ICE in sm-fd.cc [PR106551]
@ 2022-08-15 16:52 Immad Mir
0 siblings, 0 replies; only message in thread
From: Immad Mir @ 2022-08-15 16:52 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ed7e7620188dc0e653815bdd40d8802bd5446638
commit r13-2051-ged7e7620188dc0e653815bdd40d8802bd5446638
Author: Immad Mir <mirimmad@outlook.com>
Date: Mon Aug 15 22:21:27 2022 +0530
analyzer: fix for ICE in sm-fd.cc [PR106551]
This patch fixes the ICE caused by valid_to_unchecked_state
in sm-fd.cc by exiting early if first argument of any "dup"
functions is invalid.
gcc/analyzer/ChangeLog:
PR analyzer/106551
* sm-fd.cc (check_for_dup): exit early if first
argument is invalid for all dup functions.
gcc/testsuite/ChangeLog:
PR analyzer/106551
* gcc.dg/analyzer/fd-dup-1.c: New testcase.
Signed-off-by: Immad Mir <mirimmad@outlook.com>
Diff:
---
gcc/analyzer/sm-fd.cc | 3 +--
gcc/testsuite/gcc.dg/analyzer/fd-dup-1.c | 11 +++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc
index e02b86baad1..505d598f3f0 100644
--- a/gcc/analyzer/sm-fd.cc
+++ b/gcc/analyzer/sm-fd.cc
@@ -976,8 +976,7 @@ fd_state_machine::check_for_dup (sm_context *sm_ctxt, const supernode *node,
{
check_for_open_fd (sm_ctxt, node, stmt, call, callee_fndecl,
DIRS_READ_WRITE);
- if (kind == DUP_1)
- return;
+ return;
}
switch (kind)
{
diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-dup-1.c b/gcc/testsuite/gcc.dg/analyzer/fd-dup-1.c
index b971d31b1c7..b4f43e7f0ef 100644
--- a/gcc/testsuite/gcc.dg/analyzer/fd-dup-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/fd-dup-1.c
@@ -245,4 +245,15 @@ test_22 (int flags)
close (fd);
}
+void do_something();
+void
+test_23 ()
+{
+ int nullfd = -1;
+ int fd = 1;
+ if (dup2 (nullfd, fd) < 0) /* { dg-warning "'dup2' on possibly invalid file descriptor 'nullfd'" } */
+ {
+ do_something();
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-15 16:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 16:52 [gcc r13-2051] analyzer: fix for ICE in sm-fd.cc [PR106551] Immad Mir
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).