git_libgit2_opts: validate key

This commit is contained in:
Edward Thomson 2016-02-22 23:04:40 -05:00
parent 5bc93eaea0
commit 7bab2e8fbf
2 changed files with 9 additions and 0 deletions

View File

@ -181,6 +181,9 @@ int git_libgit2_opts(int key, ...)
} }
break; break;
default:
giterr_set(GITERR_INVALID, "invalid option key");
error = -1;
} }
va_end(ap); va_end(ap);

View File

@ -17,3 +17,9 @@ void test_core_opts__readwrite(void)
cl_assert(new_val == old_val); cl_assert(new_val == old_val);
} }
void test_core_opts__invalid_option(void)
{
cl_git_fail(git_libgit2_opts(-1, "foobar"));
}