This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Tue, Dec 19, 2017 at 11:59:45AM +0100, Andreas Schwab wrote:
> On Dez 18 2017, Aurelien Jarno <aurelien@aurel32.net> wrote:
>
> > @@ -433,22 +443,33 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
> > {
> > char *cp;
> > size_t nelems = 0;
> > - char *to_free;
> >
> > while ((cp = __strsep (&rpath, sep)) != NULL)
> > {
> > struct r_search_path_elem *dirp;
> > -
> > - to_free = cp = expand_dynamic_string_token (l, cp, 1);
> > -
> > - size_t len = strlen (cp);
> > + char *to_free = NULL;
> > + size_t len;
> >
> > /* `strsep' can pass an empty string. This has to be
> > interpreted as `use the current directory'. */
> > - if (len == 0)
> > + if (*cp == '\0')
> > {
> > static const char curwd[] = "./";
> > cp = (char *) curwd;
> > + len = 0;
> > + }
>
> I wonder why we need curwd at all. Nothing below this reads past
> cp[len] anyway.
Yes, I think `cp' could be left unchanged; the code below may access cp[0],
so it cannot be set to NULL, though.
The code could be simplified further, e.g.
size_t len = 0;
if (*cp != '\0')
{
to_free = cp = expand_dynamic_string_token (l, cp, 1);
...
}
--
ldv
Attachment:
signature.asc
Description: PGP signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |