commit - 6d7eb4f7d125c942358a1f8edf1d350e74141112
commit + a4435ef028e15d8a253cd768f608f9b852efd0ec
blob - d43ed3e568eed641142fe3b93aec55273e0b2876
blob + bc3deeee5a66ff48fabca32c4fa4a63f30d4ba4d
--- 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;
}