commit - 5202bcb0ad315ef2e0b80d183118906724921094fbbea43bd892aef98fc50dd7
commit + eaa483e7cb2f757f63882e6add0714c0f10b06df842f7a87658b4d2e8d1a6573
blob - cd43af6f232741d02637e8dc2808ff3d8fc364083ce4687099a1be3fafdacf10
blob + f18707e09ce0efae0d1f7afb411360363da30d483e2f7e47ce24de4242af612b
--- lib/worktree.c
+++ lib/worktree.c
read_ignores(struct got_pathlist_head *ignores, const char *path, FILE *f)
{
const struct got_error *err = NULL;
- struct got_pathlist_entry *pe = NULL;
+ struct got_pathlist_entry *pe = NULL, *ipe = NULL;
struct got_pathlist_head *ignorelist;
char *line = NULL, *pattern, *dirpath = NULL;
size_t linesize = 0;
err = got_error_from_errno("asprintf");
goto done;
}
- err = got_pathlist_insert(NULL, ignorelist, pattern, NULL);
+ err = got_pathlist_insert(&ipe, ignorelist, pattern, NULL);
+ /*
+ * got_pathlist_insert() silently rejects duplicated pattern;
+ * free it.
+ */
+ if (err || ipe == NULL)
+ free(pattern);
if (err)
goto done;
}