]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
proc_loadavg: use must_* alloc helpers
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 5 Jun 2020 11:11:39 +0000 (13:11 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 5 Jun 2020 11:11:39 +0000 (13:11 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/proc_loadavg.c

index 62e9fe565761c6c936c580dd770c432430534794..6a0b61752b8c531c8c112b196041fb2e73e815af 100644 (file)
@@ -220,15 +220,8 @@ int proc_loadavg_read(char *buf, size_t size, off_t offset,
                        return read_file_fuse("/proc/loadavg", buf, size, d);
                }
 
-               do {
-                       n = malloc(sizeof(struct load_node));
-               } while (!n);
-
-               do {
-                       n->cg = malloc(strlen(cg) + 1);
-               } while (!n->cg);
-
-               strcpy(n->cg, cg);
+               n = must_realloc(NULL, sizeof(struct load_node));
+               n->cg = must_copy_string(cg);
                n->avenrun[0] = 0;
                n->avenrun[1] = 0;
                n->avenrun[2] = 0;