[lxc-devel] [PATCH 8/8] attach: implement remaining options of lxc_attach_set_environment

Serge Hallyn serge.hallyn at ubuntu.com
Wed Aug 14 22:10:02 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
> Hi Serge,
> 
> >> +					if (!extra_keep_store[i]) {
> >> +						SYSERROR("failed to allocate memory for storing current "
> >> +						         "environment variable values that will be kept");
> >> +						while (i > 0)
> >> +							free(extra_keep_store[--i]);
> >> +						free(extra_keep_store);
> >> +						return -1;
> > 
> > The freeing seems unnecessary as you're about to rexit(-1), right?
> 
> in the current flow, yes. However, this function may be useful from
> other places where one does not exit if it fails, so I'd rather be a bit
> defensive in the programming style, if possible.

In that case should you also free if the clearenv() fails?




More information about the lxc-devel mailing list