From: Serge Hallyn Date: Tue, 20 Aug 2013 21:29:29 +0000 (-0500) Subject: coverity: don't bother getting template path if we're not going to measure it X-Git-Tag: lxc-1.0.0.alpha1~1^2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4569e93217fe9a18af35b4475c8f8eac1436759;p=thirdparty%2Flxc.git coverity: don't bother getting template path if we're not going to measure it This should also fix a memory leak, since we were freeing it under ifdef but always allocating it. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 39789fd24..7a0f657aa 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -863,11 +863,12 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet bool prepend_lxc_header(char *path, const char *t, char *const argv[]) { size_t flen; - char *contents, *tpath; + char *contents; FILE *f; #if HAVE_LIBGNUTLS int i, ret; unsigned char md_value[SHA_DIGEST_LENGTH]; + char *tpath; bool have_tpath = false; #endif @@ -908,13 +909,13 @@ bool prepend_lxc_header(char *path, const char *t, char *const argv[]) return false; } +#if HAVE_LIBGNUTLS if ((tpath = get_template_path(t)) < 0) { ERROR("bad template: %s\n", t); free(contents); return false; } -#if HAVE_LIBGNUTLS if (tpath) { have_tpath = true; ret = sha1sum_file(tpath, md_value);