1999-05-02 Ulrich Drepper <drepper@cygnus.com>
+ * sysdeps/posix/getaddrinfo.c (gaih_inet_serv): Change fourth
+ parameter to struct gaih_servtuple *. Adapt appropriately.
+ (gaih_inet): Use alloca to allocate room for gaih_inet_serv calls.
+ This fixes a memory leak.
+ Reported by Mikolaj J. Habryn <dichro-glibcbug@rcpt.to>.
+
* sysdeps/unix/sysv/linux/sys/procfs.h: Remove greg_t, gregset_t,
and fpregset_t definition. They are defined in ucontext.h.
static int
gaih_inet_serv (const char *servicename, struct gaih_typeproto *tp,
- struct gaih_servtuple **st)
+ struct gaih_servtuple *st)
{
struct servent *s;
size_t tmpbuflen = 1024;
}
while (r);
- *st = malloc (sizeof (struct gaih_servtuple));
- if (*st == NULL)
- return -EAI_MEMORY;
-
- (*st)->next = NULL;
- (*st)->socktype = tp->socktype;
- (*st)->protocol = tp->protocol;
- (*st)->port = s->s_port;
+ st->next = NULL;
+ st->socktype = tp->socktype;
+ st->protocol = tp->protocol;
+ st->port = s->s_port;
return 0;
}
{
if (tp->name != NULL)
{
- if ((rc = gaih_inet_serv (service->name, tp, &st)))
+ st = (struct gaih_servtuple *)
+ __alloca (sizeof (struct gaih_servtuple));
+
+ if ((rc = gaih_inet_serv (service->name, tp, st)))
return rc;
}
else
struct gaih_servtuple **pst = &st;
for (tp++; tp->name; tp++)
{
- if ((rc = gaih_inet_serv (service->name, tp, pst)))
+ struct gaih_servtuple *newp = (struct gaih_servtuple *)
+ __alloca (sizeof (struct gaih_servtuple));
+
+ if ((rc = gaih_inet_serv (service->name, tp, newp)))
{
if (rc & GAIH_OKIFUNSPEC)
continue;
return rc;
}
- pst = &((*pst)->next);
+
+ *pst = newp;
+ pst = &(newp->next);
}
if (st == &nullserv)
return (GAIH_OKIFUNSPEC | -EAI_SERVICE);