bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Error "Cannot allocate memory" incorrectly reported in som


From: Dmitry V. Levin
Subject: Re: [Bug-tar] Error "Cannot allocate memory" incorrectly reported in some cases.
Date: Sat, 29 Oct 2005 03:59:09 +0400

On Fri, Oct 28, 2005 at 04:07:53PM -0700, Paul Eggert wrote:
> I installed this patch instead, both in gnulib and coreutils.
[...]
> @@ -70,7 +70,6 @@ char *
>  savedir (const char *dir)
>  {
>    DIR *dirp;
> -  struct dirent *dp;
>    char *name_space;
>    size_t allocated = NAME_SIZE_DEFAULT;
>    size_t used = 0;
> @@ -82,12 +81,19 @@ savedir (const char *dir)
>  
>    name_space = xmalloc (allocated);
>  
> -  errno = 0;
> -  while ((dp = readdir (dirp)) != NULL)
> +  for (;;)
>      {
> +      struct dirent const *dp;
> +      char const *entry;
> +
> +      errno = 0;
> +      dp = readdir (dirp);
> +      if (! dp)
> +     break;
> +

I must say here that if errno is used to test for readdir() errors like in
this example, then errno should be cleared before each readdir() call, not
just before first one.  Similar issue exists in lib/getcwd.c


-- 
ldv

Attachment: pgpMhrnvl47OZ.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]