error involving a file name to be expanded here wouldn't ever
be issued. Use realloc and fall back on using a static buffer
if memory allocation fails. */
- buf = realloc (buf, n_bytes_needed);
+ char *new_buf = realloc (buf, n_bytes_needed);
n_allocated = n_bytes_needed;
- if (buf == NULL)
+ if (new_buf == NULL)
{
#define SBUF_SIZE 512
#define ELLIPSES_PREFIX "[...]"
size_t len;
char *p;
+ free (buf);
len = right_justify (static_buf, SBUF_SIZE, filename,
filename_len + 1, &p, &truncated);
right_justify (static_buf, len, dir_name, dir_len, &p, &truncated);
}
return p;
}
+
+ buf = new_buf;
}
if (filename_len == 1 && *filename == '.' && dir_len)