diff options
| author | Edward Thomson <ethomson@github.com> | 2016-02-22 23:04:40 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-02-22 23:07:30 -0500 |
| commit | 7bab2e8fbf302fc7d7732ee92652271015db2a58 (patch) | |
| tree | d756764c30f83075a079600f776694d13ec35d37 | |
| parent | 5bc93eaea0ce133caab0aa169789f73f0c0bc4ae (diff) | |
| download | libgit2-7bab2e8fbf302fc7d7732ee92652271015db2a58.tar.gz | |
git_libgit2_opts: validate key
| -rw-r--r-- | src/settings.c | 3 | ||||
| -rw-r--r-- | tests/core/opts.c | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/settings.c b/src/settings.c index da99b59e2..d7341abe8 100644 --- a/src/settings.c +++ b/src/settings.c @@ -181,6 +181,9 @@ int git_libgit2_opts(int key, ...) } break; + default: + giterr_set(GITERR_INVALID, "invalid option key"); + error = -1; } va_end(ap); diff --git a/tests/core/opts.c b/tests/core/opts.c index 3173c648b..72408cbe8 100644 --- a/tests/core/opts.c +++ b/tests/core/opts.c @@ -17,3 +17,9 @@ void test_core_opts__readwrite(void) cl_assert(new_val == old_val); } + +void test_core_opts__invalid_option(void) +{ + cl_git_fail(git_libgit2_opts(-1, "foobar")); +} + |
