[lxc-devel] [PATCH 4/4] coverity: fix leak when ipv6 gw is auto
Dwight Engen
dwight.engen at oracle.com
Fri May 3 16:56:02 UTC 2013
On Fri, 3 May 2013 11:27:54 -0500
Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> Quoting Dwight Engen (dwight.engen at oracle.com):
> > Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
>
> Thanks. To prevent future snafus it might be worth declaring gw just
> in that block, but
Yeah, I just moved the use inside the block. I'm all for a style that
says we should declare variables in "as small a scope as needed", but
it doesn't really seem to me like lxc is doing that now :)
> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
>
> > ---
> > src/lxc/confile.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/lxc/confile.c b/src/lxc/confile.c
> > index d0a404f..fbae861 100644
> > --- a/src/lxc/confile.c
> > +++ b/src/lxc/confile.c
> > @@ -782,12 +782,6 @@ static int config_network_ipv6_gateway(const
> > char *key, const char *value, if (!netdev)
> > return -1;
> >
> > - gw = malloc(sizeof(*gw));
> > - if (!gw) {
> > - SYSERROR("failed to allocate ipv6 gateway
> > address");
> > - return -1;
> > - }
> > -
> > if (!value) {
> > ERROR("no ipv6 gateway address specified");
> > return -1;
> > @@ -797,6 +791,12 @@ static int config_network_ipv6_gateway(const
> > char *key, const char *value, netdev->ipv6_gateway = NULL;
> > netdev->ipv6_gateway_auto = true;
> > } else {
> > + gw = malloc(sizeof(*gw));
> > + if (!gw) {
> > + SYSERROR("failed to allocate ipv6 gateway
> > address");
> > + return -1;
> > + }
> > +
> > if (!inet_pton(AF_INET6, value, gw)) {
> > SYSERROR("invalid ipv6 gateway address:
> > %s", value); free(gw);
> > --
> > 1.8.1.4
> >
> >
> > ------------------------------------------------------------------------------
> > Get 100% visibility into Java/.NET code with AppDynamics Lite
> > It's a free troubleshooting tool designed for production
> > Get down to code-level detail for bottlenecks, with <2% overhead.
> > Download for free and get started troubleshooting in minutes.
> > http://p.sf.net/sfu/appdyn_d2d_ap2
> > _______________________________________________
> > Lxc-devel mailing list
> > Lxc-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/lxc-devel
More information about the lxc-devel
mailing list