chiark / gitweb /
udev/collect: avoid initalizing memory twice
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Mar 2013 00:05:42 +0000 (20:05 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Mar 2013 19:40:37 +0000 (15:40 -0400)
src/udev/collect/collect.c

index 7850cfa4187ef0394260ff0ceac190faee55ee82..6580a091e0a95890f0975b0131030a135e2d08cb 100644 (file)
@@ -139,12 +139,14 @@ static int checkout(int fd)
 
  restart:
         len = bufsize >> 1;
-        buf = calloc(1,bufsize + 1);
+        buf = malloc(bufsize + 1);
         if (!buf) {
                 fprintf(stderr, "Out of memory.\n");
                 return log_oom();
         }
         memset(buf, ' ', bufsize);
+        buf[bufsize] = '\0';
+
         ptr = buf + len;
         while ((read(fd, buf + len, len)) > 0) {
                 while (ptr && *ptr) {