On Tue, 2021-02-02 at 12:57 -0700, Martin Sebor via Gcc-patches wrote:
> The strlen pass initializes its pointer_query member object with
> a cache consisting of a couple of vec's.  Because vec doesn't
> implement RAII its memory must be explicitly released to avoid
> memory leaks.  The attached patch adds a dtor to
> the strlen_dom_walker to do that.
> 
> Tested on x86_64-linux and by verifying that the cache leaks are
> gone by compiling gcc.dg/Wstringop-overflow*.c tests under Valgrind.
> 
> I'll plan to commit this change as "obvious" tomorrow unless there
> are suggestions for changes.

Why not make the vecs within struct pointer_query::cache_type's be
auto_vecs?  Then presumably the autogenerated dtor for
pointer_query::cache_type would clean things up, as called from the
autogenerated dtor for strlen_dom_walker, when cleaning up the
var_cache field?

Or am I missing something?  (sorry, I'm not familiar with this code)
Dave

> Martin
> 
> PS Valgrind shows a fair number of leaks even with the patch but
> none of them due to the pointer_query cache.


Reply via email to