blob: 61b8d31bb1468b397392cc933165350e75b74ecb [file] [log] [blame]
nethercoteeb0592d2004-11-05 12:02:27 +00001#include <assert.h>
2#include <stdlib.h>
3#include <sys/poll.h>
4
5// At one point, poll()'s checking was not done accurately. This test
6// exposes this -- previously Memcheck only found one error, now if finds
7// two.
8
9int main(void)
10{
11 // Under-allocate by one byte so we get an addressability error.
12 struct pollfd* ufds = malloc(2 * sizeof(struct pollfd) - 1);
13 assert(ufds);
14
15 ufds[0].fd = 0;
16 ufds[0].events = 0;
17 //ufds[1].fd = 0; // leave undefined so we get another error.
18 ufds[1].events = 0;
19
20 // Previously, the bounds-error due to the under-allocation was detected,
21 // but not the undefined value error due to ufds[1].fd not being defined.
22 poll(ufds, 2, 200);
23
24 return 0;
25}