Memory leak when both HS_FLAG_UTF8 + HS_FLAG_CASELESS are used
- Dominant language
- C++
- Stars
- 5.5k
- Forks
- 816
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 2
Description
Compiling simplegrep.c, but with `HS_FLAG_UTF8 | HS_FLAG_CASELESS` instead of `HS_FLAG_DOTALL`, results in a small (16-byte) leak reported by both `valgrind` and, on macOS, `leaks`.
Valgrind identifies it as originating from:
```
16 bytes in 1 blocks are definitely lost in loss record 14 of 343
==85261== at 0x100E74545: malloc (in /usr/local/Cellar/valgrind/HEAD-6ff08b6/libexec/valgrind/vgpreload_memcheck-amd64-darwin.so)
==85261== by 0x100EF23FD: __cxa_get_globals (in /usr/local/Cellar/gcc/11.2.0/lib/gcc/11/libstdc++.6.dylib)
==85261== by 0x10093F277: ??? (in ..)
==85261== by 0x100EF33C2: __cxa_throw (in /usr/local/Cellar/gcc/11.2.0/lib/gcc/11/libstdc++.6.dylib)
==85261== by 0x1056639AF: ???
==85261== by 0x105663A2F: ???
==85261== by 0x108460BBF: ???
==85261== by 0x10077BFF6: ue2::ConstructLiteralVisitor::pre(ue2::ComponentAlternation const&) (in ..)
==85261== by 0x1056639DF: ???
==85261== by 0x1004F578C: ue2::ComponentAlternation::accept(ue2::ConstComponentVisitor&) const (in ..)
==85261== by 0x108467127: ???
==85261== by 0x105663A2F: ???
...
```
In my own tests, the same issue occurs with `hs_compile_multi()` and the leak size is always 16 bytes regardless of the number of patterns or the size of the input
Contributor guide
Assessment
This issue has not been assessed yet.