summaryrefslogtreecommitdiffstats
path: root/test/bug
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/bug/.gitignore3
-rw-r--r--test/bug/Makefile6
-rw-r--r--test/bug/example-valgrind.txt250
-rw-r--r--test/bug/prog.c29
4 files changed, 288 insertions, 0 deletions
diff --git a/test/bug/.gitignore b/test/bug/.gitignore
new file mode 100644
index 0000000..973b081
--- /dev/null
+++ b/test/bug/.gitignore
@@ -0,0 +1,3 @@
+a.out
+s.html
+valgrind-out.txt
diff --git a/test/bug/Makefile b/test/bug/Makefile
new file mode 100644
index 0000000..88dfd75
--- /dev/null
+++ b/test/bug/Makefile
@@ -0,0 +1,6 @@
+default:
+ curl -H "User-Agent: Nokia WAP Gateway 4.1 CD1/ECD13_D/4.1.04)" "http://wap.google.com/search?q=libxml2&num=100&ie=UTF-8" > s.html
+ gcc -Wall -pedantic -g prog.c $$(xml2-config --cflags --libs)
+
+valgrind:
+ valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./a.out s.html
diff --git a/test/bug/example-valgrind.txt b/test/bug/example-valgrind.txt
new file mode 100644
index 0000000..13a8bea
--- /dev/null
+++ b/test/bug/example-valgrind.txt
@@ -0,0 +1,250 @@
+==31983== Memcheck, a memory error detector
+==31983== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
+==31983== Using Valgrind-3.16.1-36d6727e1d-20200622X and LibVEX; rerun with -h for copyright info
+==31983== Command: ./sear.c
+==31983== Parent PID: 31982
+==31983==
+--31983--
+--31983-- Valgrind options:
+--31983-- --leak-check=full
+--31983-- --show-leak-kinds=all
+--31983-- --track-origins=yes
+--31983-- --verbose
+--31983-- --log-file=valgrind-out.txt
+--31983-- Contents of /proc/version:
+--31983-- Linux version 5.10.0-8-686-pae (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.46-4 (2021-08-03)
+--31983--
+--31983-- Arch and hwcaps: X86, LittleEndian, x86-mmxext-sse1-sse2-sse3
+--31983-- Page sizes: currently 4096, max supported 4096
+--31983-- Valgrind library directory: /usr/lib/i386-linux-gnu/valgrind
+--31983-- Reading syms from /home/a/projects/sear.c/sear.c
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/ld-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/dc/670cc30bc6fa0d1eda127a7b90991fe834df22.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/valgrind/memcheck-x86-linux
+--31983-- Considering /usr/lib/debug/.build-id/31/675c23a8bb0b9cc8165905b7c42c350891faba.debug ..
+--31983-- .. build-id is valid
+--31983-- object doesn't have a dynamic symbol table
+--31983-- Scheduler: using generic scheduler lock implementation.
+--31983-- Reading suppressions file: /usr/lib/i386-linux-gnu/valgrind/default.supp
+==31983== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-31983-by-a-on-???
+==31983== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-31983-by-a-on-???
+==31983== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-31983-by-a-on-???
+==31983==
+==31983== TO CONTROL THIS PROCESS USING vgdb (which you probably
+==31983== don't want to do, unless you know exactly what you're doing,
+==31983== or are doing some strange experiment):
+==31983== /usr/bin/vgdb --pid=31983 ...command...
+==31983==
+==31983== TO DEBUG THIS PROCESS USING GDB: start GDB like this
+==31983== /path/to/gdb ./sear.c
+==31983== and then give GDB the following command
+==31983== target remote | /usr/bin/vgdb --pid=31983
+==31983== --pid is optional if only one valgrind process is running
+==31983==
+--31983-- REDIR: 0x401d950 (ld-linux.so.2:strlen) redirected to 0x580c489d (vgPlain_x86_linux_REDIR_FOR_strlen)
+--31983-- REDIR: 0x401d6b0 (ld-linux.so.2:index) redirected to 0x580c4878 (vgPlain_x86_linux_REDIR_FOR_index)
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/valgrind/vgpreload_core-x86-linux.so
+--31983-- Considering /usr/lib/debug/.build-id/e8/1255a6ad8a76ac3f8417dea7a2845c6c0c4fa1.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/valgrind/vgpreload_memcheck-x86-linux.so
+--31983-- Considering /usr/lib/debug/.build-id/a8/40b96e742e02d898730a45f3e1e7a93396ec83.debug ..
+--31983-- .. build-id is valid
+==31983== WARNING: new redirection conflicts with existing -- ignoring it
+--31983-- old: 0x0401d950 (strlen ) R-> (0000.0) 0x580c489d vgPlain_x86_linux_REDIR_FOR_strlen
+--31983-- new: 0x0401d950 (strlen ) R-> (2007.0) 0x04839c30 strlen
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libxml2.so.2.9.10
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libm-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/96/3a273546c86b705fac6a35dc00ec08425a6aab.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libpthread-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/b9/08ee509a4f0d7a9b8a683fafdd56fc2b8c1452.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libc-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/5e/c744c5f00b41d8449d105c55ebd96c3efa3a0f.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libdl-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/59/fbf8455e886a9ad5a97e562674a0506797c72d.debug ..
+--31983-- .. build-id is valid
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libicuuc.so.67.1
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libz.so.1.2.11
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/liblzma.so.5.2.5
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libgnutls.so.30.29.1
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libicudata.so.67.1
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libstdc++.so.6.0.28
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libgcc_s.so.1
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libp11-kit.so.0.3.0
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libidn2.so.0.3.7
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libunistring.so.2.1.0
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libtasn1.so.6.6.0
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libnettle.so.8.4
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libhogweed.so.6.4
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libgmp.so.10.4.1
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libffi.so.7.1.0
+--31983-- object doesn't have a symbol table
+--31983-- REDIR: 0x4c0e260 (libc.so.6:strncasecmp) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c14180 (libc.so.6:memrchr) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c27d60 (libc.so.6:wcslen) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0cd50 (libc.so.6:strcmp) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0dfd0 (libc.so.6:memmove) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0e3a0 (libc.so.6:memcpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0df90 (libc.so.6:bcmp) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0e1a0 (libc.so.6:stpcpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0ccd0 (libc.so.6:strcat) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0cdc0 (libc.so.6:strcpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c95bd0 (libc.so.6:__memcpy_chk) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0cd10 (libc.so.6:index) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d290 (libc.so.6:strlen) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0e020 (libc.so.6:memset) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d300 (libc.so.6:strncat) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c95c20 (libc.so.6:__memmove_chk) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0df50 (libc.so.6:memchr) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d380 (libc.so.6:strncpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0e1e0 (libc.so.6:stpncpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d2d0 (libc.so.6:strnlen) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d340 (libc.so.6:strncmp) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d3c0 (libc.so.6:rindex) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0ce00 (libc.so.6:strcspn) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d400 (libc.so.6:strpbrk) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0d6b0 (libc.so.6:strspn) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c0db60 (libc.so.6:strstr) redirected to 0x483e8e0 (strstr)
+--31983-- REDIR: 0x4c26f10 (libc.so.6:__GI_strrchr) redirected to 0x4839670 (__GI_strrchr)
+--31983-- REDIR: 0x4c273b0 (libc.so.6:__GI_strlen) redirected to 0x4839bb0 (__GI_strlen)
+--31983-- REDIR: 0x4c14430 (libc.so.6:__GI_strncmp) redirected to 0x483a2e0 (__GI_strncmp)
+--31983-- REDIR: 0x4c26d50 (libc.so.6:__GI_strchr) redirected to 0x4839790 (__GI_strchr)
+--31983-- REDIR: 0x4c27160 (libc.so.6:__GI_strcmp) redirected to 0x483ab40 (__GI_strcmp)
+--31983-- REDIR: 0x4c09030 (libc.so.6:malloc) redirected to 0x48365d0 (malloc)
+--31983-- REDIR: 0x4c26a20 (libc.so.6:__GI_memcpy) redirected to 0x483b890 (__GI_memcpy)
+--31983-- REDIR: 0x4c09df0 (libc.so.6:calloc) redirected to 0x4838970 (calloc)
+--31983-- REDIR: 0x4c144e0 (libc.so.6:__strlen_sse2_bsf) redirected to 0x4839b90 (strlen)
+--31983-- REDIR: 0x4cd1cd0 (libc.so.6:__memcpy_ssse3) redirected to 0x483b4b0 (memcpy)
+--31983-- REDIR: 0x4c254c0 (libc.so.6:__strchr_sse2_bsf) redirected to 0x4839820 (index)
+--31983-- REDIR: 0x4cd1cc0 (libc.so.6:__memcpy_chk_ssse3) redirected to 0x483e7e0 (__memcpy_chk)
+--31983-- REDIR: 0x4cde2b0 (libc.so.6:__strcmp_ssse3) redirected to 0x483aaf0 (strcmp)
+--31983-- REDIR: 0x4c09630 (libc.so.6:free) redirected to 0x4837800 (free)
+--31983-- REDIR: 0x4c257c0 (libc.so.6:__memchr_sse2_bsf) redirected to 0x483acd0 (memchr)
+--31983-- REDIR: 0x4c0fb80 (libc.so.6:strchrnul) redirected to 0x483e280 (strchrnul)
+--31983-- REDIR: 0x4c26b10 (libc.so.6:__GI_mempcpy) redirected to 0x483e4a0 (__GI_mempcpy)
+--31983-- REDIR: 0x4c1fbd0 (libc.so.6:__strcat_ssse3) redirected to 0x4839850 (strcat)
+--31983-- REDIR: 0x4c26590 (libc.so.6:__GI_memchr) redirected to 0x483ad00 (__GI_memchr)
+--31983-- REDIR: 0x4ce3620 (libc.so.6:__strncasecmp_ssse3) redirected to 0x483a530 (strncasecmp)
+--31983-- REDIR: 0x4c27240 (libc.so.6:__GI_strpbrk) redirected to 0x483eaf0 (strpbrk)
+--31983-- REDIR: 0x4c27470 (libc.so.6:__GI_stpcpy) redirected to 0x483d030 (__GI_stpcpy)
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libnss_files-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/0d/43cdeb1dd698c21bebab4455ebde7b5d85bebf.debug ..
+--31983-- .. build-id is valid
+--31983-- REDIR: 0x4c0e220 (libc.so.6:strcasecmp) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c270d0 (libc.so.6:__GI_strcpy) redirected to 0x4839d50 (__GI_strcpy)
+--31983-- REDIR: 0x4ce1110 (libc.so.6:__strcasecmp_ssse3) redirected to 0x483a430 (strcasecmp)
+--31983-- REDIR: 0x4c26aa0 (libc.so.6:__GI_memmove) redirected to 0x483dad0 (__GI_memmove)
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libnss_mdns4_minimal.so.2
+--31983-- object doesn't have a symbol table
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libresolv-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/ca/f47cd6f5ff926f5e6386471488e12148aee78d.debug ..
+--31983-- .. build-id is valid
+--31983-- REDIR: 0x4c0fb40 (libc.so.6:rawmemchr) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- Reading syms from /usr/lib/i386-linux-gnu/libnss_dns-2.31.so
+--31983-- Considering /usr/lib/debug/.build-id/a8/37dd2371868244dc863eb11f871c0c3236e50b.debug ..
+--31983-- .. build-id is valid
+--31983-- REDIR: 0x4c0e060 (libc.so.6:mempcpy) redirected to 0x482f1f0 (_vgnU_ifunc_wrapper)
+--31983-- REDIR: 0x4c09880 (libc.so.6:realloc) redirected to 0x4838bd0 (realloc)
+--31983-- REDIR: 0x4c26730 (libc.so.6:__GI_memcmp) redirected to 0x483cc80 (__GI_memcmp)
+--31983-- REDIR: 0x4cdf720 (libc.so.6:__strncmp_ssse3) redirected to 0x483a270 (strncmp)
+--31983-- REDIR: 0x4cd5cb0 (libc.so.6:__memmove_ssse3) redirected to 0x483d770 (memmove)
+--31983-- REDIR: 0x4c15e60 (libc.so.6:__strncpy_ssse3) redirected to 0x4839e30 (strncpy)
+--31983-- REDIR: 0x4ce8540 (libc.so.6:__memcmp_ssse3) redirected to 0x483ce30 (bcmp)
+--31983-- REDIR: 0x4c14610 (libc.so.6:__strcpy_ssse3) redirected to 0x4839c70 (strcpy)
+--31983-- REDIR: 0x4ccf630 (libc.so.6:__memset_sse2) redirected to 0x483d680 (memset)
+--31983-- Discarding syms at 0x871c300-0x87228c4 in /usr/lib/i386-linux-gnu/libnss_files-2.31.so (have_dinfo 1)
+--31983-- Discarding syms at 0x872f210-0x8730684 in /usr/lib/i386-linux-gnu/libnss_mdns4_minimal.so.2 (have_dinfo 1)
+--31983-- Discarding syms at 0x874e1c0-0x8750ea4 in /usr/lib/i386-linux-gnu/libnss_dns-2.31.so (have_dinfo 1)
+--31983-- Discarding syms at 0x87373b0-0x8743c64 in /usr/lib/i386-linux-gnu/libresolv-2.31.so (have_dinfo 1)
+==31983==
+==31983== HEAP SUMMARY:
+==31983== in use at exit: 543 bytes in 4 blocks
+==31983== total heap usage: 15,397 allocs, 15,393 frees, 1,396,018 bytes allocated
+==31983==
+==31983== Searching for pointers to 4 not-freed blocks
+==31983== Checked 220,616 bytes
+==31983==
+==31983== 1 bytes in 1 blocks are indirectly lost in loss record 1 of 4
+==31983== at 0x483663B: malloc (vg_replace_malloc.c:307)
+==31983== by 0x49257E4: xmlStrdup (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488CF5F: xmlCopyError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488D2F3: __xmlRaiseError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E04B5: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E4946: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E57BC: htmlParseDocument (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E5CEF: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x109585: parseHtmlDocument (lib.c:5)
+==31983== by 0x10AFBE: sc_query_google (api.c:201)
+==31983== by 0x10C300: sc_httpd (httpd.c:176)
+==31983== by 0x4A39F1B: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983==
+==31983== 2 bytes in 1 blocks are indirectly lost in loss record 2 of 4
+==31983== at 0x483663B: malloc (vg_replace_malloc.c:307)
+==31983== by 0x49257E4: xmlStrdup (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488CF6C: xmlCopyError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488D2F3: __xmlRaiseError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E04B5: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E4946: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E57BC: htmlParseDocument (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E5CEF: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x109585: parseHtmlDocument (lib.c:5)
+==31983== by 0x10AFBE: sc_query_google (api.c:201)
+==31983== by 0x10C300: sc_httpd (httpd.c:176)
+==31983== by 0x4A39F1B: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983==
+==31983== 24 bytes in 1 blocks are indirectly lost in loss record 3 of 4
+==31983== at 0x483663B: malloc (vg_replace_malloc.c:307)
+==31983== by 0x49257E4: xmlStrdup (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488CF54: xmlCopyError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x488D2F3: __xmlRaiseError (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E04B5: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E4946: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E57BC: htmlParseDocument (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E5CEF: ??? (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x109585: parseHtmlDocument (lib.c:5)
+==31983== by 0x10AFBE: sc_query_google (api.c:201)
+==31983== by 0x10C300: sc_httpd (httpd.c:176)
+==31983== by 0x4A39F1B: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983==
+==31983== 543 (516 direct, 27 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
+==31983== at 0x4838A16: calloc (vg_replace_malloc.c:760)
+==31983== by 0x492265E: xmlGetGlobalState (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x49217EC: __htmlDefaultSAXHandler (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x48E5F36: htmlNewParserCtxt (in /usr/lib/i386-linux-gnu/libxml2.so.2.9.10)
+==31983== by 0x10955E: parseHtmlDocument (lib.c:4)
+==31983== by 0x10AFBE: sc_query_google (api.c:201)
+==31983== by 0x10C300: sc_httpd (httpd.c:176)
+==31983== by 0x4A39F1B: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983== by 0x4A3BDF6: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983== by 0x4A3DF6C: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983== by 0x4A415E4: ??? (in /usr/lib/i386-linux-gnu/libmicrohttpd.so.12.57.0)
+==31983== by 0x4B6A0B3: start_thread (pthread_create.c:477)
+==31983==
+==31983== LEAK SUMMARY:
+==31983== definitely lost: 516 bytes in 1 blocks
+==31983== indirectly lost: 27 bytes in 3 blocks
+==31983== possibly lost: 0 bytes in 0 blocks
+==31983== still reachable: 0 bytes in 0 blocks
+==31983== suppressed: 0 bytes in 0 blocks
+==31983==
+==31983== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
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;
+}