diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-24 20:22:12 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-24 20:22:12 +0200 |
commit | 7988979a722b4cdf287b2093956a76a3f19b9897 (patch) | |
tree | d35e251d0472ceca55a2eef61cff261c8ee68fab /test/stdio/fclose-loop.c |
add uClibc-ng test directory
Diffstat (limited to 'test/stdio/fclose-loop.c')
-rw-r--r-- | test/stdio/fclose-loop.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/stdio/fclose-loop.c b/test/stdio/fclose-loop.c new file mode 100644 index 0000000..fc0cc42 --- /dev/null +++ b/test/stdio/fclose-loop.c @@ -0,0 +1,21 @@ +/* From: Denis Vlasenko <vda.linux@googlemail.com> + * With certain combination of .config options fclose() does not + * remove FILE* pointer from _stdio_openlist. As a result, subsequent + * fopen() may allocate new FILE structure exactly in place of one + * freed by previous fclose(), which then makes _stdio_openlist + * circularlt looped. The following program will enter infinite loop + * trying to walk _stdio_openlist in exit(): + */ + +#include <stdlib.h> +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + FILE* fp; + fp = fopen("/dev/null", "r"); + fclose(fp); + fp = fopen("/dev/zero", "r"); + fclose(fp); + return 0; +} |