1 // commit: 72ed3d47e567b1635a35d3c1d174c8a8b2787e30 2014-07-17 2 // regexec should not crash on non-zero nmatch with REG_NOSUB 3 #include <regex.h> 4 #include "test.h" 5 main(void)6int main(void) 7 { 8 regex_t re; 9 int r; 10 11 r = regcomp(&re, "abc", REG_NOSUB); 12 if (r) 13 t_error("regcomp failed: %d\n", r); 14 r = regexec(&re, "zyx abc", 1, 0, 0); 15 if (r == REG_NOMATCH) 16 t_error("regexec failed to match\n"); 17 else if (r) 18 t_error("regexec returned invalid code: %d\n", r); 19 regfree(&re); 20 return t_status; 21 } 22