don't leak memory and do call END_UTMP_ENT.
/* GNU's read utmp module.
/* GNU's read utmp module.
- Copyright (C) 1992-2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-2001, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
n_read = 0;
while ((u = GET_UTMP_ENT ()) != NULL)
{
n_read = 0;
while ((u = GET_UTMP_ENT ()) != NULL)
{
- utmp = (STRUCT_UTMP *) realloc (utmp, n_read * sizeof (STRUCT_UTMP));
- if (utmp == NULL)
- return 1;
+ p = (STRUCT_UTMP *) realloc (utmp, n_read * sizeof (STRUCT_UTMP));
+ if (p == NULL)
+ {
+ free (utmp);
+ END_UTMP_ENT ();
+ return 1;
+ }
+ utmp = p;