[PATCH 06/19] scan-tree: use struct strbuf instead of static buffers
Jason A. Donenfeld
Jason at zx2c4.com
Sun Apr 7 13:29:47 CEST 2013
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?
Are there other cases of this elsewhere?
More information about the CGit
mailing list