From: Qiang Huang Date: Wed, 15 Jan 2014 02:45:18 +0000 (+0800) Subject: lxccontainer.c: check lxc_conf before referance haltsignal X-Git-Tag: lxc-1.0.0.beta2~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b022744452e07085a6b0fd1d110fee77263a2581;p=thirdparty%2Flxc.git lxccontainer.c: check lxc_conf before referance haltsignal If we start container with rcfile(see comments in lxc_start.c), it is possible that we have no config file in /usr/local/var/lib/lxc. So when we try lxc_stop, lxc_container_new will not load any config so we'll get c->lxc_conf = NULL. In that case, we'll get Segmentation fault in lxcapi_shutdown, a simple check would fix this. Signed-off-by: Qiang Huang Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 8462ba581..0bebdff1b 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1313,7 +1313,7 @@ static bool lxcapi_shutdown(struct lxc_container *c, int timeout) pid = c->init_pid(c); if (pid <= 0) return true; - if (c->lxc_conf->haltsignal) + if (c->lxc_conf && c->lxc_conf->haltsignal) haltsignal = c->lxc_conf->haltsignal; kill(pid, haltsignal); retv = c->wait(c, "STOPPED", timeout);