From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Sun, 7 Apr 2013 12:33:01 +0100 Subject: [PATCH 06/19] scan-tree: use struct strbuf instead of static buffers In-Reply-To: References: Message-ID: <20130407113301.GX2222@serenity.lan> 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 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.