aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/asan/pr98920.c
blob: 789a2a37b0b3d3b2aadeae2e31dfd48f099690d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* PR sanitizer/98920 */
/* { dg-do run } */

#include <stdio.h>
#include <sys/types.h>
#if __has_include(<regex.h>)
#include <regex.h>
#endif

int main(void)
{
#ifdef REG_STARTEND
    regex_t r;
    const char s[] = "ban\0ana";
    regmatch_t pmatch[10];
    pmatch[0].rm_so = 0;
    pmatch[0].rm_eo = sizeof(s);
    if (regcomp(&r, "ana", 0))
        return 2;
    if (regexec(&r, s, sizeof(pmatch)/sizeof(pmatch[0]), pmatch, REG_STARTEND)) {
        fprintf(stderr, "failed to match\n");
        regfree(&r);
        return 3;
    }
    regfree(&r);
#endif
    return 0;
}