-
-
Save dndx/45cdea90139cd031e8b604d7aad80614 to your computer and use it in GitHub Desktop.
Program to reproduce the PCRE JIT Valgrind warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include "pcre.h" | |
int main(void) { | |
pcre_extra *sd; | |
pcre *re; | |
const char *errstr; | |
int erroff, rc; | |
const char *ver = pcre_version(); | |
char *reg = strdup("b"); | |
char *sub = strdup("a"); | |
fprintf(stderr, "running: %s\n", ver); | |
re = pcre_compile(reg, 0, &errstr, &erroff, NULL); | |
if (!re) { | |
fprintf(stderr, "pcre_compile() failed"); | |
return 1; | |
} | |
sd = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &errstr); | |
if (!sd || errstr) { | |
fprintf(stderr, "pcre_study() failed"); | |
return 1; | |
} | |
rc = pcre_exec(re, sd, sub, 1, 0, 0, NULL, | |
0); | |
if (rc != PCRE_ERROR_NOMATCH) { | |
fprintf(stderr, "pcre_exec() failed: %d\n", rc); | |
} | |
pcre_free_study(sd); | |
pcre_free(re); | |
free(reg); | |
free(sub); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result is: