diff --git a/test/ref/test_gets.c b/test/ref/test_gets.c index 7d7c18e3ae..003da55699 100644 --- a/test/ref/test_gets.c +++ b/test/ref/test_gets.c @@ -30,9 +30,7 @@ char *argv[]; #endif { /* Fake stdin with the reference file */ - fclose(stdin); - stdin = fopen(INFILE, "rb"); - if (stdin == NULL) { + if (freopen(INFILE, "rb", stdin) == NULL) { return EXIT_FAILURE; }