unchecked `malloc' calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

In browsing through the code, I noticed that there are many
places in which the code doesn't check for malloc returning NULL.
E.g.,

  ./virsh.c:    ids = malloc(sizeof(int) * maxid);
  ./virsh.c-    virConnectListDomains(ctl->conn, &ids[0], maxid);

  ./virsh.c:    *res = malloc(sz + 1);
  ./virsh.c-    memcpy(*res, tkstr, sz);

  ./virsh.c:        res = malloc(strlen(name) + 3);
  ./virsh.c-        sprintf(res, "--%s", name);

  ./xmlrpc.c:    buf = malloc(sizeof(*buf));
  ./xmlrpc.c-    buf->size = 1024;

  ./xmlrpc.c:    xmlRpcValueDictElementPtr ret = malloc(sizeof(*ret));
  ./xmlrpc.c-    xmlNodePtr cur;
  ./xmlrpc.c-
  ./xmlrpc.c-    memset(ret, 0, sizeof(*ret));

At first, seeing so many, I thought there must be a wrapper
that handles the case of a NULL return value.  But there are
many places where the code *does* check for NULL.

This may be a clue.  Maybe it's planned...

  ./libvirt.c: * TODO:
  ...
  ./libvirt.c: * - memory wrappers for malloc/free ?

Jim


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]