Hi Jonathan,

2012/3/28 Jonathan K. Bullard <jkbull...@gmail.com>:
> There is one part of check_cmd_access() which I took from code in
> run_up_down() and I am not sure about -- the three lines:
>   gc_arena gc;
> and
>   gc = gc_new ();
> and
>   gc_free (&gc);
>
> Are they needed? I put them in because I assume that they set up and tear
> down a global garbage-collection area where allocations are made, and that
> that area is used by argv_new() and whatever eventually allocates the argv
> structure's components when they are created by argv_printf() and/or
> parse_line().

gc_arena instances are used by explicitly passing a pointer to it. So,
unless one of the functions takes an instance of gc_arena as a
parameter, you don't need to prepare one. As many functions in OpenVPN
take one, there's some dead code scattered about that needlessly
creates and frees gc arenas (probably because uses have come and gone
over time). So you can drop gc because it's not used.

The argv family of functions apparently has its own memory management
and therefore argv_new() should be paired with an argv_reset().
Otherwise the memory allocated by argv_printf() is leaked.

Cheers
Fabian

Reply via email to