blob: fc0cc424aa98785c4c8e27c282dd35887c4d9c92 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* 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
13int 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}