diff --git a/src/sort.c b/src/sort.c index 3dc7ae0b7..a8d0c142b 100644 --- a/src/sort.c +++ b/src/sort.c @@ -2767,7 +2767,8 @@ check (char const *file_name, char checkonly) } while (alloc < line->length); - temp.text = xrealloc (temp.text, alloc); + free (temp.text); + temp.text = xmalloc (alloc); } memcpy (temp.text, line->text, line->length); temp.length = line->length; @@ -2907,7 +2908,8 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles, } while ((savealloc *= 2) < smallest->length); - saved.text = xrealloc (saved.text, savealloc); + free (saved.text); + saved.text = xmalloc (savealloc); } saved.length = smallest->length; memcpy (saved.text, smallest->text, saved.length); diff --git a/src/who.c b/src/who.c index 2c0d94790..ac988816b 100644 --- a/src/who.c +++ b/src/who.c @@ -410,7 +410,8 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime) if (hostlen < strlen (host) + strlen (display) + 4) { hostlen = strlen (host) + strlen (display) + 4; - hoststr = xrealloc (hoststr, hostlen); + free (hoststr); + hoststr = xmalloc (hostlen); } sprintf (hoststr, "(%s:%s)", host, display); } @@ -419,7 +420,8 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime) if (hostlen < strlen (host) + 3) { hostlen = strlen (host) + 3; - hoststr = xrealloc (hoststr, hostlen); + free (hoststr); + hoststr = xmalloc (hostlen); } sprintf (hoststr, "(%s)", host); } @@ -432,7 +434,8 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime) if (hostlen < 1) { hostlen = 1; - hoststr = xrealloc (hoststr, hostlen); + free (hoststr); + hoststr = xmalloc (hostlen); } *hoststr = '\0'; }