From: Kyle J. McKay Date: Sat, 17 Aug 2013 19:18:24 GMT Subject: Re: [RFC PATCHv2] repack: rewrite the shell script in C. Message-ID: In-Reply-To: <520F7BDE.9090902@web.de> On Aug 17, 2013, at 06:34, René Scharfe wrote: > On Aug 15, 2013, at 17:12, Stefan Beller wrote: >> + if (sha_begin >= e->d_name && !strncmp(sha_begin, sha1, 40)) { >> + char *fname; >> + fname = xmalloc(strlen(path) + 1 + strlen(e->d_name)); This needs another +1 because >> + sprintf(fname, "%s/%s", path, e->d_name); len(path) + len("/") + len(e->d_name) + len("\0") > > mkpathdup.. > >> + unlink(fname); >> + /*TODO: free(fname); fails here sometimes, needs investigation*/ > > Strange. Perhaps valgrind can tell you what's wrong. which is probably why it fails since the byte beyond the end of fname is being overwritten with a nul.