Skip to content

Commit 7bab2e8

Browse files
author
Edward Thomson
committed
git_libgit2_opts: validate key
1 parent 5bc93ea commit 7bab2e8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ int git_libgit2_opts(int key, ...)
181181
}
182182

183183
break;
184+
default:
185+
giterr_set(GITERR_INVALID, "invalid option key");
186+
error = -1;
184187
}
185188

186189
va_end(ap);

tests/core/opts.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ void test_core_opts__readwrite(void)
1717

1818
cl_assert(new_val == old_val);
1919
}
20+
21+
void test_core_opts__invalid_option(void)
22+
{
23+
cl_git_fail(git_libgit2_opts(-1, "foobar"));
24+
}
25+

0 commit comments

Comments
 (0)