[PATCH 06/19] scan-tree: use struct strbuf instead of static buffers

John Keeping john at keeping.me.uk
Sun Apr 7 13:33:01 CEST 2013


On Sun, Apr 07, 2013 at 01:29:47PM +0200, Jason A. Donenfeld wrote:
> On Sun, Apr 7, 2013 at 11:29 AM, John Keeping <john at keeping.me.uk> wrote:
> >  static int is_git_dir(const char *path)
> >  {
> >         struct stat st;
> > -       static char buf[MAX_PATH];
> > +       struct strbuf pathbuf = STRBUF_INIT;
> >
> > -       if (snprintf(buf, MAX_PATH, "%s/objects", path) >= MAX_PATH) {
> > -               fprintf(stderr, "Insanely long path: %s\n", path);
> > -               return 0;
> > -       }
> > -       if (stat(buf, &st)) {
> > +       strbuf_addf(&pathbuf, "%s/objects", path);
> > +       if (stat(pathbuf.buf, &st)) {
> >                 if (errno != ENOENT)
> >                         fprintf(stderr, "Error checking path %s: %s (%d)\n",
> >                                 path, strerror(errno), errno);
> 
> strbuf_release is never called. Does this leak?

Yes.

> Are there other cases of this elsewhere?

I thought I cleaned up everywhere, hopefully this is the only one I
missed but I'll go through and check again.




More information about the CGit mailing list