]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/test/stdio/fclose-loop.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / test / stdio / fclose-loop.c
1 /* From: Denis Vlasenko <vda.linux@googlemail.com>
2  *      With certain combination of .config options fclose() does not
3  *      remove FILE* pointer from _stdio_openlist.  As a result, subsequent
4  *      fopen() may allocate new FILE structure exactly in place of one
5  *      freed by previous fclose(), which then makes _stdio_openlist
6  *      circularlt looped. The following program will enter infinite loop
7  *      trying to walk _stdio_openlist in exit():
8  */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 int main(int argc, char *argv[])
14 {
15         FILE* fp;
16         fp = fopen("/dev/null", "r");
17         fclose(fp);
18         fp = fopen("/dev/zero", "r");
19         fclose(fp);
20         return 0;
21 }