commit - 9afa3de221045d529287cc3fa75fdc2915aed5c1
commit + f0426190497546f380f3bbd5d7cf464e5423a1c6
blob - 3b6daa1a2a93121b0ee884ddd8cd1ceb5e85fa9b
blob + 44801b6de7df40ed4df2acd8f523a9ccabe7170b
--- gotd/parse.y
+++ gotd/parse.y
conf_protect_ref_namespace(struct got_pathlist_head *refs, char *namespace)
{
const struct got_error *error;
+ struct got_pathlist_entry *new;
char *s;
got_path_strip_trailing_slashes(namespace);
return -1;
}
- error = got_pathlist_insert(NULL, refs, s, NULL);
- if (error) {
- yyerror("got_pathlist_insert: %s", error->msg);
+ error = got_pathlist_insert(&new, refs, s, NULL);
+ if (error || new == NULL) {
+ free(s);
+ if (error)
+ yyerror("got_pathlist_insert: %s", error->msg);
+ else
+ yyerror("duplicate protect namespace %s", namespace);
return -1;
}
conf_protect_branch(struct gotd_repo *repo, char *branchname)
{
const struct got_error *error;
+ struct got_pathlist_entry *new;
char *refname;
if (strncmp(branchname, "refs/heads/", 11) != 0) {
return -1;
}
- error = got_pathlist_insert(NULL, &repo->protected_branches,
+ error = got_pathlist_insert(&new, &repo->protected_branches,
refname, NULL);
- if (error) {
- yyerror("got_pathlist_insert: %s", error->msg);
+ if (error || new == NULL) {
+ free(refname);
+ if (error)
+ yyerror("got_pathlist_insert: %s", error->msg);
+ else
+ yyerror("duplicate protect branch %s", branchname);
return -1;
}