]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: don't bother getting template path if we're not going to measure it
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 20 Aug 2013 21:29:29 +0000 (16:29 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 20 Aug 2013 21:30:36 +0000 (16:30 -0500)
This should also fix a memory leak, since we were freeing it under ifdef
but always allocating it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxccontainer.c

index 39789fd248efc2df5bf90881731fc3a5d8fd91c2..7a0f657aa340990a382e0841aef16a04df1edfdf 100644 (file)
@@ -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);