]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: fix resource leak
authorDwight Engen <dwight.engen@oracle.com>
Fri, 14 Feb 2014 14:49:51 +0000 (09:49 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 14 Feb 2014 15:09:45 +0000 (10:09 -0500)
also fix the check if the string will fit the local buffer

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/cgmanager.c

index 41ba3d33736cd018b634492c3b4e8a62843c4a7b..e4bd7349cd606d5c4fe9d3d8c859356bb36fdd48 100644 (file)
@@ -422,8 +422,10 @@ static inline bool cgm_create(void *hdata)
        tmp = lxc_string_replace("%n", d->name, d->cgroup_pattern);
        if (!tmp)
                return false;
-       if (strlen(tmp) > MAXPATHLEN)
+       if (strlen(tmp) >= MAXPATHLEN) {
+               free(tmp);
                return false;
+       }
        strcpy(result, tmp);
        baselen = strlen(result);
        free(tmp);