diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2021-08-22 03:18:03 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2021-08-22 03:18:03 +0200 |
commit | 387fb72ee084aca883b35d37d177958715bffab0 (patch) | |
tree | a203233340481b87dc9690bf8bb3cebea1cbb9c7 /test/bug/prog.c | |
parent | added i386 (diff) | |
download | sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar.gz sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar.bz2 sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar.lz sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar.xz sear.c-387fb72ee084aca883b35d37d177958715bffab0.tar.zst sear.c-387fb72ee084aca883b35d37d177958715bffab0.zip |
Diffstat (limited to 'test/bug/prog.c')
-rw-r--r-- | test/bug/prog.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/bug/prog.c b/test/bug/prog.c new file mode 100644 index 0000000..2371077 --- /dev/null +++ b/test/bug/prog.c @@ -0,0 +1,29 @@ +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <libxml/HTMLparser.h> +#include <string.h> +int main (int argc, char ** argv) { + xmlInitParser(); + htmlDocPtr xmldoc; + char * txtdoc; + struct stat s; + int fd = open(argv[1], O_RDONLY); + htmlParserCtxtPtr c; + stat(argv[1], &s); + txtdoc = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + xmlInitParser(); + + c = htmlNewParserCtxt(); + xmldoc = htmlCtxtReadMemory(c, txtdoc, strlen(txtdoc), "", NULL, HTML_PARSE_RECOVER); + /* by the way: why/how/when does libxml2 use networking when HTML_PARSE_NOT is not specified? */ + htmlFreeParserCtxt(c); + xmlFreeDoc(xmldoc); + + close(fd); + munmap(txtdoc, s.st_size); + xmlCleanupParser(); + return 0; +} |