diff options
| author | chiehwarm <[email protected]> | 2023-05-15 11:51:30 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-14 23:51:30 -0400 |
| commit | b1415c4fc8e47bbfd39dd3009a5df39b04937a4c (patch) | |
| tree | c0ee9cbcd2d1fba39488fd0ae8a142c0c1314e2d /examples | |
| parent | eb08036537cf67f1c2715d6de794467d162fa36b (diff) | |
[HUST CSE] fix fgets_tc.c (#7503)
这个文件里存在使用fopen函数后没有关闭文件fclose的问题,而且stream=NULL时是不需要fclose的
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; } |
