[lxc-devel] [PATCH] coverity 1097618: check for NULL return from calloc before deref

Dwight Engen dwight.engen at oracle.com
Tue Oct 29 18:49:16 UTC 2013


Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 src/lxc/cgroup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
index cf1605a..6aa4495 100644
--- a/src/lxc/cgroup.c
+++ b/src/lxc/cgroup.c
@@ -1688,6 +1688,8 @@ char *cgroup_to_absolute_path(struct cgroup_mount_point *mp, const char *path, c
 
 	len = strlen(mp->mount_point) + strlen(path) + (suffix ? strlen(suffix) : 0);
 	buf = calloc(len + 1, 1);
+	if (!buf)
+		return NULL;
 	rv = snprintf(buf, len + 1, "%s%s%s", mp->mount_point, path, suffix ? suffix : "");
 	if (rv > len) {
 		free(buf);
-- 
1.8.3.1





More information about the lxc-devel mailing list