From 317363b4c15062c196316f3df87d6204bc26b06f Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 24 Jan 2014 15:34:03 +0000 Subject: [PATCH] Avoid crashing when an input file could not be opened * input.c (add_file_to_cache_tab): Handle the case where fopen returns NULL. Signed-off-by: Dodji Seketeli From-SVN: r207046 --- gcc/ChangeLog | 5 +++++ gcc/input.c | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cdbedadc64c..7feb332d94b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-01-24 Dodji Seketeli + + * input.c (add_file_to_cache_tab): Handle the case where fopen + returns NULL. + 2014-01-23 H.J. Lu PR target/59929 diff --git a/gcc/input.c b/gcc/input.c index 290680c1e5a..547c177b09f 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -293,11 +293,8 @@ add_file_to_cache_tab (const char *file_path) { FILE *fp = fopen (file_path, "r"); - if (ferror (fp)) - { - fclose (fp); - return NULL; - } + if (fp == NULL) + return NULL; unsigned highest_use_count = 0; fcache *r = evicted_cache_tab_entry (&highest_use_count);