]> git.ipfire.org Git - thirdparty/glibc.git/blob - posix/bug-regex31.c
More regex memory leak fixes and tests.
[thirdparty/glibc.git] / posix / bug-regex31.c
1 #include <mcheck.h>
2 #include <regex.h>
3 #include <stdio.h>
4 #include <sys/types.h>
5
6 int
7 main (void)
8 {
9 mtrace ();
10
11 int res = 0;
12 char *buf = NULL;
13 size_t len = 0;
14 while (! feof (stdin))
15 {
16 ssize_t n = getline (&buf, &len, stdin);
17 if (n <= 0)
18 break;
19 if (buf[n - 1] == '\n')
20 buf[n - 1] = '\0';
21
22 regex_t regex;
23 int rc = regcomp (&regex, buf, REG_EXTENDED);
24 if (rc != 0)
25 printf ("%s: Error %d (expected)\n", buf, rc);
26 else
27 {
28 printf ("%s: succeeded !\n", buf);
29 res = 1;
30 }
31 }
32
33 free (buf);
34
35 return 0;
36 }