Commit b37b07a
committed
Fix leak in RE2::Set#add
See #104
When we raise an exception in re2_set_add, the memory used by the
std::string used to store the error message is never freed so we need to
free it ourselves manually. However, we also need a copy of what is
inside it to return to the user so we turn that into a C string first.
The maximum message size of 100 is taken from the length of the prefix
of the message (33 characters) and the longest error message currently
in RE2 (35 characters) plus a little extra in case new releases of RE2
add longer messages.
Thanks to @peterzhu2118 for both authoring ruby_memcheck and helping
find the source of these leaks.1 parent 60e3d3f commit b37b07a
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1589 | 1589 | | |
1590 | 1590 | | |
1591 | 1591 | | |
1592 | | - | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1593 | 1599 | | |
1594 | 1600 | | |
1595 | 1601 | | |
| |||
0 commit comments