commit 197aa481b5566c0549a182decf03e6a756f44041 from: Stefan Sperling date: Thu Jun 21 19:05:01 2018 UTC fix bogus free() in got_object_open_by_path() commit - 1cbc02b603bd240e29f2ca64f4f9672a32c526b2 commit + 197aa481b5566c0549a182decf03e6a756f44041 blob - f5552d9bf05a61506e908f8f664c3d7bc47096f3 blob + d5e33de294798ecea0ba650d0ea1ae10ee4c9b60 --- lib/object.c +++ lib/object.c @@ -1406,7 +1406,7 @@ got_object_open_by_path(struct got_object **obj, struc struct got_commit_object *commit = NULL; struct got_tree_object *tree = NULL; struct got_tree_entry *entry = NULL; - char *seg, *s = NULL; + char *seg, *s, *s0 = NULL; *obj = NULL; @@ -1430,15 +1430,16 @@ got_object_open_by_path(struct got_object **obj, struc if (err) goto done; - s = strdup(path); - if (s == NULL) { + s0 = strdup(path); + if (s0 == NULL) { err = got_error_from_errno(); goto done; } - err = got_canonpath(path, s, strlen(s) + 1); + err = got_canonpath(path, s0, strlen(s0) + 1); if (err) goto done; + s = s0; s++; /* skip leading '/' */ seg = s; while (*s) { @@ -1477,7 +1478,7 @@ got_object_open_by_path(struct got_object **obj, struc else err = got_error(GOT_ERR_NO_OBJ); done: - free(s); + free(s0); if (commit) got_object_commit_close(commit); if (tree)