Genivia / RE-flex

A high-performance C++ regex library and lexical analyzer generator with Unicode support. Extends Flex++ with Unicode support, indent/dedent anchors, lazy quantifiers, functions for lex and syntax error reporting and more. Seamlessly integrates with Bison and other parsers.
https://www.genivia.com/doc/reflex/html
BSD 3-Clause "New" or "Revised" License
504 stars 85 forks source link

reflex::Matcher needs a virtual destructor #174

Closed tlemo closed 1 year ago

tlemo commented 1 year ago

I just noticed that the reflex::Matcher class has virtual methods, but no virtual destructor. This is problematic when instances of classes derived from Matcher are deleted though a Matcher* pointer (specifically, w/o a virtual destructor this is undefined behavior)

The fix is trivial:

virtual ~Matcher() = default;
tlemo commented 1 year ago

Nevermind - the base classes, starting reflex::AbstractMatcher already have virtual destructors. Sorry for the false alarm.

genivia-inc commented 1 year ago

Thanks for checking. Having more eyes on the code always helps!