add ungetc with setvbuf test
[libc-test.git] / src / regression / setvbuf-unget.c
blob866767533c5525371156decea2d4fe9becfe5f29
1 // commit: 9cad27a3dc1a4eb349b6591e4dc8cc89dce32277
2 // ungetc after setvbuf should not clobber memory below buffer
3 #include <stdio.h>
4 #include <string.h>
5 #include "test.h"
7 int main(void)
9 char buf[1024] = "hello world";
10 setvbuf(stdin, buf+12, _IOFBF, sizeof buf - 12);
11 while (ungetc('x', stdin)!=EOF);
12 if (strcmp(buf, "hello world"))
13 t_error("ungetc clobbered outside buffer: [%.12s]\n", buf);
14 return t_status;