Hi,
On Thu, 23 Jan 2014 18:12:45, Jakub Jelinek wrote:
> 
> On Wed, Jan 22, 2014 at 09:16:02AM +0100, Dodji Seketeli wrote:
>> +static fcache*
>> +add_file_to_cache_tab (const char *file_path)
>> +{
>> +
>> + FILE *fp = fopen (file_path, "r");
>> + if (ferror (fp))
>> + {
>> + fclose (fp);
>> + return NULL;
>> + }
> 
> I've seen various segfaults here when playing with preprocessed sources
> from PRs (obviously don't have the original source files).
> When fopen fails, it just returns NULL, so I don't see why you just don't
> do
> if (fp == NULL)
> return fp;
> 
> Jakub

This would be a good idea for test cases too.
However the test system always calls the compiler with
-fno-diagnostics-show-caret so I doubt your test case
is actually testing anything when it is called from the
test environment with that option.

Bernd.                                    

Reply via email to