diff --git a/examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c b/examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c index 79eca7ef98..e0b2a4766a 100644 --- a/examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c +++ b/examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c @@ -19,15 +19,21 @@ static int fgets_entry(void) fclose(stream); stream = fopen("fopen_file.txt","r"); + if (stream == NULL) + { + perror("fopen fail"); + ret = -1; + goto __exit; + } fgets(gets, sizeof(gets), stream); if(strcmp(gets, data)) { ret = -1; } + fclose(stream); __exit: - fclose(stream); return ret; }