Commit b4569e93 by Serge Hallyn

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent fb760f70
...@@ -863,11 +863,12 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet ...@@ -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[]) bool prepend_lxc_header(char *path, const char *t, char *const argv[])
{ {
size_t flen; size_t flen;
char *contents, *tpath; char *contents;
FILE *f; FILE *f;
#if HAVE_LIBGNUTLS #if HAVE_LIBGNUTLS
int i, ret; int i, ret;
unsigned char md_value[SHA_DIGEST_LENGTH]; unsigned char md_value[SHA_DIGEST_LENGTH];
char *tpath;
bool have_tpath = false; bool have_tpath = false;
#endif #endif
...@@ -908,13 +909,13 @@ bool prepend_lxc_header(char *path, const char *t, char *const argv[]) ...@@ -908,13 +909,13 @@ bool prepend_lxc_header(char *path, const char *t, char *const argv[])
return false; return false;
} }
#if HAVE_LIBGNUTLS
if ((tpath = get_template_path(t)) < 0) { if ((tpath = get_template_path(t)) < 0) {
ERROR("bad template: %s\n", t); ERROR("bad template: %s\n", t);
free(contents); free(contents);
return false; return false;
} }
#if HAVE_LIBGNUTLS
if (tpath) { if (tpath) {
have_tpath = true; have_tpath = true;
ret = sha1sum_file(tpath, md_value); ret = sha1sum_file(tpath, md_value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment