On Sat, Sep 21, 2019 at 02:37:05PM +0200, René Scharfe wrote: > Am 20.09.19 um 20:13 schrieb SZEDER Gábor: > >>> @@ -280,12 +269,16 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo > >>> if (o && o->type == OBJ_COMMIT) { > >>> struct commit *commit = (struct commit *)o; > >>> int from_tag = starts_with(path, "refs/tags/"); > >>> + const char *tip_name; > >> > >> This should not be const because you allocate the buffer it points to > >> right here in the function, in each execution path. > > > > Marking it as const indicates that this function doesn't modify the > > buffer where the pointer points at. > > Right, and that's at odds with this code: > > >>> + if (deref) > >>> + tip_name = xstrfmt("%s^0", path); > >>> + else > >>> + tip_name = xstrdup(path); > > ... which allocates said memory and writes a string to it. ... before assigning it to the const pointer.