lkml.org 
[lkml]   [2007]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Stop docproc segfaulting when SRCTREE isn't set.
On Tue, 9 Oct 2007 15:03:15 +0200 Ahmed S. Darwish wrote:

> Hi Rob,
>
> On Tue, Oct 09, 2007 at 01:25:18AM -0500, Rob Landley wrote:
> [...]
> > FILE * infile;
> > +
> > + srctree = getenv("SRCTREE");
> > + if (!srctree) srctree = getcwd(NULL,0);
> > if (argc != 3) {
> > usage();
> > exit(1);
>
> $ man getcwd
>
> char *getcwd(char *buf, size_t size);
>
> As an extension to the POSIX.1 standard, Linux (libc4, libc5, glibc) getcwd()
> allocates the buffer dynamically using malloc() if buf is NULL on call.
>
> Shouldn't "srctree" be free()ed in case getenv("SRCTREE") failed ?

What is there to free() at that point? If getenv() fails (i.e.,
the env. variable is not found), it returns NULL.
or do I need another cup of coffee?

---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-10-09 17:59    [W:0.075 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site