From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Sun, 7 Apr 2013 13:29:47 +0200 Subject: [PATCH 06/19] scan-tree: use struct strbuf instead of static buffers In-Reply-To: References: Message-ID: 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? Are there other cases of this elsewhere?