Code

cgroups plugin: Use cu_mount_checkoption().
authorFlorian Forster <octo@collectd.org>
Wed, 28 Aug 2013 13:19:48 +0000 (15:19 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 28 Aug 2013 13:19:48 +0000 (15:19 +0200)
cu_mount_checkoption() behaves a bit like strstr() in that it returns a pointer
into the buffer. cu_mount_getoptionvalue() allocated memory that was never
freed, slowly leaking memory (although very little).

Github: #412

src/cgroups.c

index ffb1740a9846e5f134b61070a80976a8e5029879..a515cf5b0c62511d97cf39a18fcd864c0cee621d 100644 (file)
@@ -217,8 +217,9 @@ static int cgroups_read (void)
        {
                /* Find the cgroup mountpoint which contains the cpuacct
                 * controller. */
-               if (strcmp(mnt_ptr->type, "cgroup") != 0 ||
-                       !cu_mount_getoptionvalue(mnt_ptr->options, "cpuacct"))
+               if ((strcmp(mnt_ptr->type, "cgroup") != 0)
+                               || !cu_mount_checkoption(mnt_ptr->options,
+                                       "cpuacct", /* full = */ 1))
                        continue;
 
                walk_directory (mnt_ptr->dir, read_cpuacct_root,