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 <dodji@seketeli.org>

From-SVN: r207046
This commit is contained in:
Dodji Seketeli 2014-01-24 15:34:03 +00:00 committed by Dodji Seketeli
parent f27ad2b220
commit 317363b4c1
2 changed files with 7 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2014-01-24 Dodji Seketeli <dodji@redhat.com>
* input.c (add_file_to_cache_tab): Handle the case where fopen
returns NULL.
2014-01-23 H.J. Lu <hongjiu.lu@intel.com>
PR target/59929

View File

@ -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);