- check the return value of malloc & co.

This commit is contained in:
Takashi Iwai 2004-02-25 11:24:29 +00:00
parent 7e6569e300
commit d91948db49
7 changed files with 42 additions and 0 deletions

View file

@ -795,6 +795,8 @@ int snd_is_local(struct hostent *hent)
conf.ifc_len = numreqs * sizeof(struct ifreq);
conf.ifc_buf = malloc((unsigned int) conf.ifc_len);
if (! conf.ifc_buf)
return -ENOMEM;
while (1) {
err = ioctl(s, SIOCGIFCONF, &conf);
if (err < 0) {
@ -806,6 +808,8 @@ int snd_is_local(struct hostent *hent)
numreqs *= 2;
conf.ifc_len = numreqs * sizeof(struct ifreq);
conf.ifc_buf = realloc(conf.ifc_buf, (unsigned int) conf.ifc_len);
if (! conf.ifc_buf)
return -ENOMEM;
}
numreqs = conf.ifc_len / sizeof(struct ifreq);
for (i = 0; i < numreqs; ++i) {